Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-03-11 12:04:43
Exec Total Coverage
Lines: 1779 4256 41.8%
Functions: 128 341 37.5%
Branches: 953 2690 35.4%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 #include "zc_sys.h"
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35 #include "dialog/cheatkeys.h"
36
37 #ifdef ALLEGRO_DOS
38 #include <unistd.h>
39 #endif
40
41 #include "metadata/metadata.h"
42 #include "zelda.h"
43 #include "tiles.h"
44 #include "base/colors.h"
45 #include "pal.h"
46 #include "base/zsys.h"
47 #include "qst.h"
48 #include "zc_sys.h"
49 #include "play_midi.h"
50 #include "debug.h"
51 #include "jwin_a5.h"
52 #include "base/jwinfsel.h"
53 #include "base/gui.h"
54 #include "midi.h"
55 #include "subscr.h"
56 #include "maps.h"
57 #include "sprite.h"
58 #include "guys.h"
59 #include "hero.h"
60 #include "title.h"
61 #include "particles.h"
62 #include "zconsole.h"
63 #include "ffscript.h"
64 #include "dialog/info.h"
65 #include "dialog/alert.h"
66 #include <fmt/format.h>
67
68 #ifdef __EMSCRIPTEN__
69 #include "base/emscripten_utils.h"
70 #endif
71
72 extern FFScript FFCore;
73 extern bool Playing;
74 int32_t sfx_voice[WAV_COUNT];
75 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
76 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
77
78 extern byte monochrome_console;
79
80 extern FONT *lfont;
81 extern HeroClass Hero;
82 extern FFScript FFCore;
83 extern ZModule zcm;
84 extern zcmodule moduledata;
85 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
86 extern particle_list particles;
87 extern int32_t loadlast;
88 extern word passive_subscreen_doscript;
89 extern bool passive_subscreen_waitdraw;
90 extern char *sfx_string[WAV_COUNT];
91 byte use_dwm_flush;
92 byte use_save_indicator;
93 byte midi_patch_fix;
94 bool midi_paused=false;
95 int32_t paused_midi_pos = 0;
96 byte midi_suspended = 0;
97 byte callback_switchin = 0;
98 byte zc_192b163_warp_compatibility;
99 char modulepath[2048];
100 bool epilepsyFlashReduction;
101 signed char pause_in_background_menu_init = 0;
102 byte pause_in_background = 0;
103 bool is_sys_pal = false;
104 static bool load_control_called_this_frame;
105 extern PALETTE* hw_palette;
106 extern bool update_hw_pal;
107 extern const char* dmaplist(int32_t index, int32_t* list_size);
108 int32_t getnumber(const char *prompt,int32_t initialval);
109
110 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
111 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
112 //extern byte refresh_select_screen;
113 //extern movingblock mblock2; //mblock[4]?
114 //extern int32_t db;
115
116 static const char *ZC_str = "Zelda Classic";
117 extern char save_file_name[1024];
118 #ifdef ALLEGRO_DOS
119 const char *qst_dir_name = "dos_qst_dir";
120 #elif defined(ALLEGRO_WINDOWS)
121 const char *qst_dir_name = "win_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(ALLEGRO_LINUX)
124 const char *qst_dir_name = "linux_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #elif defined(__APPLE__)
127 const char *qst_dir_name = "osx_qst_dir";
128 static const char *qst_module_name = "current_module";
129 #endif
130 #ifdef ALLEGRO_LINUX
131 static const char *samplepath = "samplesoundset/patches.dat";
132 #endif
133 char qst_files_path[2048];
134
135 #ifdef _MSC_VER
136 #define getcwd _getcwd
137 #endif
138
139 bool rF11();
140 bool rI();
141 bool rQ();
142 bool zc_key_pressed();
143
144 #ifdef _WIN32
145
146 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
147 extern "C"
148 {
149 typedef HRESULT(WINAPI *t_DwmFlush)();
150 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
151 }
152
153 void do_DwmFlush()
154 {
155 static HMODULE shell = LoadLibrary("dwmapi.dll");
156
157 if(!shell)
158 return;
159
160 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
161 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
162
163 BOOL enabled;
164 isEnabled(&enabled);
165
166 if(isEnabled)
167 flush();
168 }
169
170 #endif // _WIN32
171
172 82019 bool flash_reduction_enabled(bool check_qr)
173 {
174
4/4
✓ Branch 0 taken 79798 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 79342 times.
✓ Branch 3 taken 81563 times.
82019 return (check_qr && get_bit(quest_rules, qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
175 }
176
177 // Dialogue largening
178 void large_dialog(DIALOG *d)
179 {
180 large_dialog(d, 1.5);
181 }
182
183 void large_dialog(DIALOG *d, float RESIZE_AMT)
184 {
185 if(!d[0].d1)
186 {
187 d[0].d1 = 1;
188 int32_t oldwidth = d[0].w;
189 int32_t oldheight = d[0].h;
190 int32_t oldx = d[0].x;
191 int32_t oldy = d[0].y;
192 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
193 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
194 d[0].w = int32_t(d[0].w*RESIZE_AMT);
195 d[0].h = int32_t(d[0].h*RESIZE_AMT);
196
197 for(int32_t i=1; d[i].proc !=NULL; i++)
198 {
199 // Place elements horizontally
200 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
201 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
202
203 if(d[i].proc != d_stringloader)
204 {
205 if(d[i].proc==d_bitmap_proc)
206 {
207 d[i].w *= 2;
208 }
209 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
210 }
211
212 // Place elements vertically
213 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
214 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
215
216 // Vertically resize elements
217 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
218 {
219 d[i].h = int32_t((double)d[i].h*1.5);
220 }
221 else if(d[i].proc == jwin_droplist_proc)
222 {
223 d[i].y += int32_t((double)d[i].h*0.25);
224 d[i].h = int32_t((double)d[i].h*1.25);
225 }
226 else if(d[i].proc==d_bitmap_proc)
227 {
228 d[i].h *= 2;
229 }
230 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
231
232 // Fix frames
233 if(d[i].proc == jwin_frame_proc)
234 {
235 d[i].x++;
236 d[i].y++;
237 d[i].w-=4;
238 d[i].h-=4;
239 }
240 }
241 }
242
243 for(int32_t i=1; d[i].proc!=NULL; i++)
244 {
245 if(d[i].proc==jwin_slider_proc)
246 continue;
247
248 // Bigger font
249 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
250
251 if(!d[i].dp2 && bigfontproc)
252 {
253 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
254 d[i].dp2 = lfont_l;
255 }
256 else if(!bigfontproc)
257 {
258 // ((ListData *)d[i].dp)->font = &sfont3;
259 ((ListData *)d[i].dp)->font = &lfont_l;
260 }
261
262 // Make checkboxes work
263 if(d[i].proc == jwin_check_proc)
264 d[i].proc = jwin_checkfont_proc;
265 else if(d[i].proc == jwin_radio_proc)
266 d[i].proc = jwin_radiofont_proc;
267 }
268
269 jwin_center_dialog(d);
270 }
271
272
273 /**********************************/
274 /******** System functions ********/
275 /**********************************/
276
277 static char cfg_sect[] = "zeldadx"; //We need to rename this.
278 static char ctrl_sect[] = "Controls";
279 static char sfx_sect[] = "Volume";
280
281 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
282 {
283 return D_O_K;
284 }
285
286 bool checkcheat(Cheat cheat)
287 {
288 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
289 return true; //Main key pressed
290 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
291 return true; //Alt key pressed
292 return false;
293 }
294 29 void load_default_cheatkeys()
295 {
296 29 memset(cheatkeys, 0, sizeof(cheatkeys));
297 29 cheatkeys[Cheat::Life][0] = KEY_H;
298 29 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
299 29 cheatkeys[Cheat::Magic][0] = KEY_M;
300 29 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
301 29 cheatkeys[Cheat::Rupies][0] = KEY_R;
302 29 cheatkeys[Cheat::Bombs][0] = KEY_B;
303 29 cheatkeys[Cheat::Arrows][0] = KEY_A;
304 29 cheatkeys[Cheat::Clock][0] = KEY_I;
305 29 cheatkeys[Cheat::Walls][0] = KEY_F11;
306 29 cheatkeys[Cheat::Fast][0] = KEY_Q;
307 29 cheatkeys[Cheat::Light][0] = KEY_L;
308 29 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
309 29 cheatkeys[Cheat::Kill][0] = KEY_K;
310 29 cheatkeys[Cheat::GoTo][0] = KEY_G;
311 29 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
312 29 cheatkeys[Cheat::ShowL0][0] = KEY_0;
313 29 cheatkeys[Cheat::ShowL1][0] = KEY_1;
314 29 cheatkeys[Cheat::ShowL2][0] = KEY_2;
315 29 cheatkeys[Cheat::ShowL3][0] = KEY_3;
316 29 cheatkeys[Cheat::ShowL4][0] = KEY_4;
317 29 cheatkeys[Cheat::ShowL5][0] = KEY_5;
318 29 cheatkeys[Cheat::ShowL6][0] = KEY_6;
319 29 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
320 29 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
321 29 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
322 29 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
323 29 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
324 29 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
325 29 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
326 29 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
327 29 }
328 29 void load_game_configs()
329 {
330 29 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
331 29 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
332 29 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
333 29 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
334 29 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
335 29 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
336 29 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
337 29 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
338 29 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
339 29 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
340 29 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
341 29 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
342 29 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
343 29 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
344 29 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
345
346 //cheat modifier keya
347 29 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
348 29 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
349 29 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
350 29 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
351
352 //cheat keys
353 29 load_default_cheatkeys();
354 char buf[256];
355 29 al_trace("START CHEATS\n");
356
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 29 times.
1044 for(size_t q = 1; q < Cheat::Last; ++q)
357 {
358
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 if(!bindable_cheat((Cheat)q)) continue;
359 1015 std::string cheatname = cheat_to_string((Cheat)q);
360
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 util::lowerstr(cheatname);
361 1015 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
362
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 al_trace("%s = %d\n", buf, cheatkeys[q][0]);
363
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
364 1015 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
365
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 al_trace("%s = %d\n", buf, cheatkeys[q][1]);
366
1/2
✓ Branch 0 taken 1015 times.
✗ Branch 1 not taken.
1015 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
367 1015 }
368 29 al_trace("END CHEATS\n");
369
370
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
371 joystick_index = 0;
372
373 29 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
374 29 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
375 29 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
376 29 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
377 29 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
378 29 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
379 29 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
380 29 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
381 29 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
382 29 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
383
384 29 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
385 29 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
386 29 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
387 29 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
388
389 29 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
390 29 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
391 29 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
392 29 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
393 29 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
394 29 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
395 29 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
396 29 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
397 29 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
398 29 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
399 29 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
400
401 29 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
402 29 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
403 29 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
404 29 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
405
406 29 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
407
408 29 digi_volume = zc_get_config(sfx_sect,"digi",248);
409 29 midi_volume = zc_get_config(sfx_sect,"midi",255);
410 29 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
411 29 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
412 29 pan_style = zc_get_config(sfx_sect,"pan",1);
413 // 1 <= zcmusic_bufsz <= 128
414 29 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
415 29 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
416 29 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
417 29 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
418 29 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
419 29 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
420 29 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
421 #ifdef __EMSCRIPTEN__
422 if (em_is_mobile()) NameEntryMode = 2;
423 #endif
424 29 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
425 29 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
426 29 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
427 29 title_version = zc_get_config(cfg_sect,"title",2);
428 29 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
429 29 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
430
431 //default - scale x2, 640 x 480
432 29 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
433 29 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
434 29 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
435 29 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
436 29 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
437
438 29 loadlast = zc_get_config(cfg_sect,"load_last",0);
439
440 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
441
442 29 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
443
444 29 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
445 29 info_opacity = zc_get_config("zc","debug_info_opacity",255);
446 #ifdef _WIN32
447 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
448 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
449 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
450 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
451
452 // This one's for Aero
453 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
454
455 // And this one fixes patches unloading on some MIDI setups
456 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
457 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
458 #else //UNIX
459 29 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
460 29 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
461 29 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
462 #endif
463 29 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
464
465 29 char const* default_path = "";
466 29 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
467
468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(strlen(qstdir)==0)
469 {
470 29 getcwd(qstdir,2048);
471 29 fix_filename_case(qstdir);
472 29 fix_filename_slashes(qstdir);
473 29 put_backslash(qstdir);
474 29 }
475 else
476 {
477 chop_path(qstdir);
478 }
479
480 29 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
481 29 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
482 29 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
483 29 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
484 29 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
485 29 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
486 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
487 29 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
488 29 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
489 29 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
490 29 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
491 29 }
492
493 void save_control_configs(bool kb)
494 {
495 if(kb)
496 {
497 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
498 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
499 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
500 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
501
502 if (!replay_is_replaying())
503 {
504 zc_set_config(ctrl_sect,"key_a",Akey);
505 zc_set_config(ctrl_sect,"key_b",Bkey);
506 zc_set_config(ctrl_sect,"key_s",Skey);
507 zc_set_config(ctrl_sect,"key_l",Lkey);
508 zc_set_config(ctrl_sect,"key_r",Rkey);
509 zc_set_config(ctrl_sect,"key_p",Pkey);
510 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
511 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
512 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
513 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
514 zc_set_config(ctrl_sect,"key_up", DUkey);
515 zc_set_config(ctrl_sect,"key_down", DDkey);
516 zc_set_config(ctrl_sect,"key_left", DLkey);
517 zc_set_config(ctrl_sect,"key_right",DRkey);
518 }
519 }
520 else
521 {
522 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
523 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
524 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
525 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
526 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
527 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
528 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
529 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
530 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
531 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
532 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
533 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
534 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
535 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
536
537 zc_set_config(ctrl_sect,"btn_a",Abtn);
538 zc_set_config(ctrl_sect,"btn_b",Bbtn);
539 zc_set_config(ctrl_sect,"btn_s",Sbtn);
540 zc_set_config(ctrl_sect,"btn_m",Mbtn);
541 zc_set_config(ctrl_sect,"btn_l",Lbtn);
542 zc_set_config(ctrl_sect,"btn_r",Rbtn);
543 zc_set_config(ctrl_sect,"btn_p",Pbtn);
544 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
545 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
546 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
547 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
548
549 zc_set_config(ctrl_sect,"btn_up",DUbtn);
550 zc_set_config(ctrl_sect,"btn_down",DDbtn);
551 zc_set_config(ctrl_sect,"btn_left",DLbtn);
552 zc_set_config(ctrl_sect,"btn_right",DRbtn);
553 }
554 }
555
556 void save_cheatkeys()
557 {
558 char buf[256];
559 for(size_t q = 1; q < Cheat::Last; ++q)
560 {
561 if(!bindable_cheat((Cheat)q)) continue;
562 std::string cheatname = cheat_to_string((Cheat)q);
563 util::lowerstr(cheatname);
564 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
565 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
566 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
567 if(cheatkeys[q][1])
568 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
569 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
570 }
571 }
572
573 void save_game_configs()
574 {
575 packfile_password("");
576
577 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
578
579 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
580 {
581 int o_window_x, o_window_y;
582 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
583 zc_set_config(cfg_sect,"window_x",o_window_x);
584 zc_set_config(cfg_sect,"window_y",o_window_y);
585 }
586
587 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
588 {
589 double monitor_scale = zc_get_monitor_scale();
590 window_width = al_get_display_width(all_get_display()) / monitor_scale;
591 window_height = al_get_display_height(all_get_display()) / monitor_scale;
592 zc_set_config(cfg_sect,"window_width",window_width);
593 zc_set_config(cfg_sect,"window_height",window_height);
594 }
595
596 zc_set_config(cfg_sect,"load_last",loadlast);
597 chop_path(qstdir);
598 zc_set_config(cfg_sect,qst_dir_name,qstdir);
599 zc_set_config("SAVEFILE","save_filename",save_file_name);
600 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
601
602 flush_config_file();
603 #ifdef __EMSCRIPTEN__
604 em_sync_fs();
605 #endif
606 }
607
608 //----------------------------------------------------------------
609
610 // Timers
611
612 27787 void fps_callback()
613 {
614 27787 lastfps=framecnt;
615 27787 dword tempsecs = fps_secs;
616 27787 ++tempsecs;
617 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
618 27787 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
619 27787 ++fps_secs;
620 27787 framecnt=0;
621 27787 }
622
623 END_OF_FUNCTION(fps_callback)
624
625 29 int32_t Z_init_timers()
626 {
627 static bool didit = false;
628 const static char *err_str = "Couldn't allocate timer";
629 29 err_str = err_str; //Unused variable warning
630
631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(didit)
632 return 1;
633
634 29 didit = true;
635
636 LOCK_VARIABLE(lastfps);
637 LOCK_VARIABLE(framecnt);
638 LOCK_FUNCTION(fps_callback);
639
640
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
641 return 0;
642
643 29 return 1;
644 29 }
645
646 void Z_remove_timers()
647 {
648 remove_int(fps_callback);
649 }
650
651 //----------------------------------------------------------------
652
653 void go()
654 {
655 scare_mouse();
656 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
657 unscare_mouse();
658 }
659
660 void comeback()
661 {
662 scare_mouse();
663 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
664 unscare_mouse();
665 }
666
667 void dump_pal(BITMAP *dest)
668 {
669 for(int32_t i=0; i<256; i++)
670 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
671 }
672
673 //----------------------------------------------------------------
674
675 //Handles converting the mouse sprite from the .dat file
676 29 void load_mouse()
677 {
678 29 system_pal();
679 29 scare_mouse();
680 29 set_mouse_sprite(NULL);
681 29 int32_t sz = vbound(int32_t(16*(zc_get_config("zeldadx","cursor_scale_large",1.5))),16,80);
682
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t j = 0; j < 4; ++j)
683 {
684 116 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
685 116 BITMAP* subbmp = create_bitmap_ex(8,16,16);
686
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(zcmouse[j])
687 destroy_bitmap(zcmouse[j]);
688 116 zcmouse[j] = create_bitmap_ex(8,sz,sz);
689 116 clear_bitmap(zcmouse[j]);
690 116 clear_bitmap(tmpbmp);
691 116 clear_bitmap(subbmp);
692 116 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
693
2/2
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 116 times.
1972 for(int32_t x = 0; x < 16; ++x)
694 {
695
2/2
✓ Branch 0 taken 29696 times.
✓ Branch 1 taken 1856 times.
31552 for(int32_t y = 0; y < 16; ++y)
696 {
697 29696 int32_t color = getpixel(tmpbmp, x, y);
698
5/5
✓ Branch 0 taken 27318 times.
✓ Branch 1 taken 551 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 667 times.
✓ Branch 4 taken 522 times.
29696 switch(color)
699 {
700 case dvc(1):
701 551 color = jwin_pal[jcCURSORMISC];
702 551 break;
703 case dvc(2):
704 638 color = jwin_pal[jcCURSOROUTLINE];
705 638 break;
706 case dvc(3):
707 667 color = jwin_pal[jcCURSORLIGHT];
708 667 break;
709 case dvc(5):
710 522 color = jwin_pal[jcCURSORDARK];
711 522 break;
712 }
713 29696 putpixel(subbmp, x, y, color);
714 29696 }
715 1856 }
716
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(sz!=16)
717 116 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
718 else
719 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
720 116 destroy_bitmap(tmpbmp);
721 116 destroy_bitmap(subbmp);
722 116 }
723 29 set_mouse_sprite(zcmouse[0]);
724
725 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
726 29 set_palette(*hw_palette);
727 29 show_mouse(screen);
728 29 show_mouse(NULL);
729
730 29 unscare_mouse();
731 29 game_pal();
732 29 }
733
734 // sets the video mode and initializes the palette and mouse sprite
735 29 bool game_vid_mode(int32_t mode,int32_t wait)
736 {
737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
738 {
739 return false;
740 }
741
742 29 scrx = (resx-320)>>1;
743 29 scry = (resy-240)>>1;
744
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 29 times.
145 for(int32_t q = 0; q < 4; ++q)
745 116 zcmouse[q] = NULL;
746 29 load_mouse();
747 29 set_mouse_sprite(zcmouse[0]);
748
749
2/2
✓ Branch 0 taken 464 times.
✓ Branch 1 taken 29 times.
493 for(int32_t i=240; i<256; i++)
750 464 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
751
752 29 set_palette(RAMpal);
753 29 clear_to_color(screen,BLACK);
754
755 29 rest(wait);
756 29 return true;
757 29 }
758
759 5 void null_quest()
760 {
761 char qstdat_string[2048];
762 5 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
763 5 strcat(qstdat_string,"#NESQST_NEW_QST");
764
765 #ifdef __EMSCRIPTEN__
766 // The quest template data file is not included because it's really big and isn't really needed
767 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
768 // which is much smaller.
769 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
770 #endif
771
772 5 byte skip_flags[4] = { 0 };
773
774 5 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
775 5 }
776
777 5 void init_NES_mode()
778 {
779 /*
780 // qst.dat may not load correctly without this...
781 QHeader.templatepath[0]='\0';
782
783 if(!init_colordata(true, &QHeader, &QMisc))
784 {
785 return;
786 }
787
788 loadfullpal();
789 init_tiles(false, &QHeader);
790 */
791 5 null_quest();
792 5 }
793
794 //----------------------------------------------------------------
795
796 qword trianglelines[16]=
797 {
798 0x0000000000000000ULL,
799 0xFD00000000000000ULL,
800 0xFDFD000000000000ULL,
801 0xFDFDFD0000000000ULL,
802 0xFDFDFDFD00000000ULL,
803 0xFDFDFDFDFD000000ULL,
804 0xFDFDFDFDFDFD0000ULL,
805 0xFDFDFDFDFDFDFD00ULL,
806 0xFDFDFDFDFDFDFDFDULL,
807 0x00FDFDFDFDFDFDFDULL,
808 0x0000FDFDFDFDFDFDULL,
809 0x000000FDFDFDFDFDULL,
810 0x00000000FDFDFDFDULL,
811 0x0000000000FDFDFDULL,
812 0x000000000000FDFDULL,
813 0x00000000000000FDULL,
814 };
815
816 word screen_triangles[28][32];
817 /*
818 qword triangles[4][16]= //[direction][value]
819 {
820 {
821 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
822 },
823 {
824 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
825 },
826 {
827 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
828 },
829 {
830 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
831 }
832 };
833 */
834
835
836 /*
837 byte triangles[4][16][8]= //[direction][value][line]
838 {
839 {
840 {
841 0, 0, 0, 0, 0, 0, 0, 0
842 },
843 {
844 1, 0, 0, 0, 0, 0, 0, 0
845 },
846 {
847 2, 1, 0, 0, 0, 0, 0, 0
848 },
849 {
850 3, 2, 1, 0, 0, 0, 0, 0
851 },
852 {
853 4, 3, 2, 1, 0, 0, 0, 0
854 },
855 {
856 5, 4, 3, 2, 1, 0, 0, 0
857 },
858 {
859 6, 5, 4, 3, 2, 1, 0, 0
860 },
861 {
862 7, 6, 5, 4, 3, 2, 1, 0
863 },
864 {
865 8, 7, 6, 5, 4, 3, 2, 1
866 },
867 {
868 8, 8, 7, 6, 5, 4, 3, 2
869 },
870 {
871 8, 8, 8, 7, 6, 5, 4, 3
872 },
873 {
874 8, 8, 8, 8, 7, 6, 5, 4
875 },
876 {
877 8, 8, 8, 8, 8, 7, 6, 5
878 },
879 {
880 8, 8, 8, 8, 8, 8, 7, 6
881 },
882 {
883 8, 8, 8, 8, 8, 8, 8, 7
884 },
885 {
886 8, 8, 8, 8, 8, 8, 8, 8
887 }
888 },
889 {
890 {
891 0, 0, 0, 0, 0, 0, 0, 0
892 },
893 {
894 15, 0, 0, 0, 0, 0, 0, 0
895 },
896 {
897 14, 15, 0, 0, 0, 0, 0, 0
898 },
899 {
900 13, 14, 15, 0, 0, 0, 0, 0
901 },
902 {
903 12, 13, 14, 15, 0, 0, 0, 0
904 },
905 {
906 11, 12, 13, 14, 15, 0, 0, 0
907 },
908 {
909 10, 11, 12, 13, 14, 15, 0, 0
910 },
911 {
912 9, 10, 11, 12, 13, 14, 15, 0
913 },
914 {
915 8, 9, 10, 11, 12, 13, 14, 15
916 },
917 {
918 8, 8, 9, 10, 11, 12, 13, 14
919 },
920 {
921 8, 8, 8, 9, 10, 11, 12, 13
922 },
923 {
924 8, 8, 8, 8, 9, 10, 11, 12
925 },
926 {
927 8, 8, 8, 8, 8, 9, 10, 11
928 },
929 {
930 8, 8, 8, 8, 8, 8, 9, 10
931 },
932 {
933 8, 8, 8, 8, 8, 8, 8, 9
934 },
935 {
936 8, 8, 8, 8, 8, 8, 8, 8
937 }
938 },
939 {
940 {
941 0, 0, 0, 0, 0, 0, 0, 0
942 },
943 {
944 0, 0, 0, 0, 0, 0, 0, 1
945 },
946 {
947 0, 0, 0, 0, 0, 0, 1, 2
948 },
949 {
950 0, 0, 0, 0, 0, 1, 2, 3
951 },
952 {
953 0, 0, 0, 0, 1, 2, 3, 4
954 },
955 {
956 0, 0, 0, 1, 2, 3, 4, 5
957 },
958 {
959 0, 0, 1, 2, 3, 4, 5, 6
960 },
961 {
962 0, 1, 2, 3, 4, 5, 6, 7
963 },
964 {
965 1, 2, 3, 4, 5, 6, 7, 8
966 },
967 {
968 2, 3, 4, 5, 6, 7, 8, 8
969 },
970 {
971 3, 4, 5, 6, 7, 8, 8, 8
972 },
973 {
974 4, 5, 6, 7, 8, 8, 8, 8
975 },
976 {
977 5, 6, 7, 8, 8, 8, 8, 8
978 },
979 {
980 6, 7, 8, 8, 8, 8, 8, 8
981 },
982 {
983 7, 8, 8, 8, 8, 8, 8, 8
984 },
985 {
986 8, 8, 8, 8, 8, 8, 8, 8
987 }
988 },
989 {
990 {
991 0, 0, 0, 0, 0, 0, 0, 0
992 },
993 {
994 0, 0, 0, 0, 0, 0, 0, 15
995 },
996 {
997 0, 0, 0, 0, 0, 0, 15, 14
998 },
999 {
1000 0, 0, 0, 0, 0, 15, 14, 13
1001 },
1002 {
1003 0, 0, 0, 0, 15, 14, 13, 12
1004 },
1005 {
1006 0, 0, 0, 15, 14, 13, 12, 11
1007 },
1008 {
1009 0, 0, 15, 14, 13, 12, 11, 10
1010 },
1011 {
1012 0, 15, 14, 13, 12, 11, 10, 9
1013 },
1014 {
1015 15, 14, 13, 12, 11, 10, 9, 8
1016 },
1017 {
1018 14, 13, 12, 11, 10, 9, 8, 8
1019 },
1020 {
1021 13, 12, 11, 10, 9, 8, 8, 8
1022 },
1023 {
1024 12, 11, 10, 9, 8, 8, 8, 8
1025 },
1026 {
1027 11, 10, 9, 8, 8, 8, 8, 8
1028 },
1029 {
1030 10, 9, 8, 8, 8, 8, 8, 8
1031 },
1032 {
1033 9, 8, 8, 8, 8, 8, 8, 8
1034 },
1035 {
1036 8, 8, 8, 8, 8, 8, 8, 8
1037 }
1038 }
1039 };
1040 */
1041
1042
1043
1044 /*
1045 for (int32_t blockrow=0; blockrow<30; ++i)
1046 {
1047 for (int32_t linerow=0; linerow<8; ++i)
1048 {
1049 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1050 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1051 {
1052 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1053 ++triangleline;
1054 }
1055 }
1056 }
1057 */
1058
1059 // the ULL suffixes are to prevent this warning:
1060 // warning: integer constant is too large for "int32_t" type
1061
1062 qword triangles[4][16][8]= //[direction][value][line]
1063 {
1064 {
1065 {
1066 0x0000000000000000ULL,
1067 0x0000000000000000ULL,
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL
1074 },
1075 {
1076 0xFD00000000000000ULL,
1077 0x0000000000000000ULL,
1078 0x0000000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL
1084 },
1085 {
1086 0xFDFD000000000000ULL,
1087 0xFD00000000000000ULL,
1088 0x0000000000000000ULL,
1089 0x0000000000000000ULL,
1090 0x0000000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL
1094 },
1095 {
1096 0xFDFDFD0000000000ULL,
1097 0xFDFD000000000000ULL,
1098 0xFD00000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL
1104 },
1105 {
1106 0xFDFDFDFD00000000ULL,
1107 0xFDFDFD0000000000ULL,
1108 0xFDFD000000000000ULL,
1109 0xFD00000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL
1114 },
1115 {
1116 0xFDFDFDFDFD000000ULL,
1117 0xFDFDFDFD00000000ULL,
1118 0xFDFDFD0000000000ULL,
1119 0xFDFD000000000000ULL,
1120 0xFD00000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL
1124 },
1125 {
1126 0xFDFDFDFDFDFD0000ULL,
1127 0xFDFDFDFDFD000000ULL,
1128 0xFDFDFDFD00000000ULL,
1129 0xFDFDFD0000000000ULL,
1130 0xFDFD000000000000ULL,
1131 0xFD00000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL
1134 },
1135 {
1136 0xFDFDFDFDFDFDFD00ULL,
1137 0xFDFDFDFDFDFD0000ULL,
1138 0xFDFDFDFDFD000000ULL,
1139 0xFDFDFDFD00000000ULL,
1140 0xFDFDFD0000000000ULL,
1141 0xFDFD000000000000ULL,
1142 0xFD00000000000000ULL,
1143 0x0000000000000000ULL
1144 },
1145 {
1146 0xFDFDFDFDFDFDFDFDULL,
1147 0xFDFDFDFDFDFDFD00ULL,
1148 0xFDFDFDFDFDFD0000ULL,
1149 0xFDFDFDFDFD000000ULL,
1150 0xFDFDFDFD00000000ULL,
1151 0xFDFDFD0000000000ULL,
1152 0xFDFD000000000000ULL,
1153 0xFD00000000000000ULL
1154 },
1155 {
1156 0xFDFDFDFDFDFDFDFDULL,
1157 0xFDFDFDFDFDFDFDFDULL,
1158 0xFDFDFDFDFDFDFD00ULL,
1159 0xFDFDFDFDFDFD0000ULL,
1160 0xFDFDFDFDFD000000ULL,
1161 0xFDFDFDFD00000000ULL,
1162 0xFDFDFD0000000000ULL,
1163 0xFDFD000000000000ULL
1164 },
1165 {
1166 0xFDFDFDFDFDFDFDFDULL,
1167 0xFDFDFDFDFDFDFDFDULL,
1168 0xFDFDFDFDFDFDFDFDULL,
1169 0xFDFDFDFDFDFDFD00ULL,
1170 0xFDFDFDFDFDFD0000ULL,
1171 0xFDFDFDFDFD000000ULL,
1172 0xFDFDFDFD00000000ULL,
1173 0xFDFDFD0000000000ULL
1174 },
1175 {
1176 0xFDFDFDFDFDFDFDFDULL,
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFD00ULL,
1181 0xFDFDFDFDFDFD0000ULL,
1182 0xFDFDFDFDFD000000ULL,
1183 0xFDFDFDFD00000000ULL
1184 },
1185 {
1186 0xFDFDFDFDFDFDFDFDULL,
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFD00ULL,
1192 0xFDFDFDFDFDFD0000ULL,
1193 0xFDFDFDFDFD000000ULL
1194 },
1195 {
1196 0xFDFDFDFDFDFDFDFDULL,
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFD00ULL,
1203 0xFDFDFDFDFDFD0000ULL
1204 },
1205 {
1206 0xFDFDFDFDFDFDFDFDULL,
1207 0xFDFDFDFDFDFDFDFDULL,
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFD00ULL
1214 },
1215 {
1216 0xFDFDFDFDFDFDFDFDULL,
1217 0xFDFDFDFDFDFDFDFDULL,
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL
1224 }
1225 },
1226 {
1227 {
1228 0x0000000000000000ULL,
1229 0x0000000000000000ULL,
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL
1236 },
1237 {
1238 0x00000000000000FDULL,
1239 0x0000000000000000ULL,
1240 0x0000000000000000ULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL
1246 },
1247 {
1248 0x000000000000FDFDULL,
1249 0x00000000000000FDULL,
1250 0x0000000000000000ULL,
1251 0x0000000000000000ULL,
1252 0x0000000000000000ULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL
1256 },
1257 {
1258 0x0000000000FDFDFDULL,
1259 0x000000000000FDFDULL,
1260 0x00000000000000FDULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL
1266 },
1267 {
1268 0x00000000FDFDFDFDULL,
1269 0x0000000000FDFDFDULL,
1270 0x000000000000FDFDULL,
1271 0x00000000000000FDULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL
1276 },
1277 {
1278 0x000000FDFDFDFDFDULL,
1279 0x00000000FDFDFDFDULL,
1280 0x0000000000FDFDFDULL,
1281 0x000000000000FDFDULL,
1282 0x00000000000000FDULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL
1286 },
1287 {
1288 0x0000FDFDFDFDFDFDULL,
1289 0x000000FDFDFDFDFDULL,
1290 0x00000000FDFDFDFDULL,
1291 0x0000000000FDFDFDULL,
1292 0x000000000000FDFDULL,
1293 0x00000000000000FDULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL
1296 },
1297 {
1298 0x00FDFDFDFDFDFDFDULL,
1299 0x0000FDFDFDFDFDFDULL,
1300 0x000000FDFDFDFDFDULL,
1301 0x00000000FDFDFDFDULL,
1302 0x0000000000FDFDFDULL,
1303 0x000000000000FDFDULL,
1304 0x00000000000000FDULL,
1305 0x0000000000000000ULL
1306 },
1307 {
1308 0xFDFDFDFDFDFDFDFDULL,
1309 0x00FDFDFDFDFDFDFDULL,
1310 0x0000FDFDFDFDFDFDULL,
1311 0x000000FDFDFDFDFDULL,
1312 0x00000000FDFDFDFDULL,
1313 0x0000000000FDFDFDULL,
1314 0x000000000000FDFDULL,
1315 0x00000000000000FDULL
1316 },
1317 {
1318 0xFDFDFDFDFDFDFDFDULL,
1319 0xFDFDFDFDFDFDFDFDULL,
1320 0x00FDFDFDFDFDFDFDULL,
1321 0x0000FDFDFDFDFDFDULL,
1322 0x000000FDFDFDFDFDULL,
1323 0x00000000FDFDFDFDULL,
1324 0x0000000000FDFDFDULL,
1325 0x000000000000FDFDULL
1326 },
1327 {
1328 0xFDFDFDFDFDFDFDFDULL,
1329 0xFDFDFDFDFDFDFDFDULL,
1330 0xFDFDFDFDFDFDFDFDULL,
1331 0x00FDFDFDFDFDFDFDULL,
1332 0x0000FDFDFDFDFDFDULL,
1333 0x000000FDFDFDFDFDULL,
1334 0x00000000FDFDFDFDULL,
1335 0x0000000000FDFDFDULL
1336 },
1337 {
1338 0xFDFDFDFDFDFDFDFDULL,
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0x00FDFDFDFDFDFDFDULL,
1343 0x0000FDFDFDFDFDFDULL,
1344 0x000000FDFDFDFDFDULL,
1345 0x00000000FDFDFDFDULL
1346 },
1347 {
1348 0xFDFDFDFDFDFDFDFDULL,
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0x00FDFDFDFDFDFDFDULL,
1354 0x0000FDFDFDFDFDFDULL,
1355 0x000000FDFDFDFDFDULL
1356 },
1357 {
1358 0xFDFDFDFDFDFDFDFDULL,
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0x00FDFDFDFDFDFDFDULL,
1365 0x0000FDFDFDFDFDFDULL
1366 },
1367 {
1368 0xFDFDFDFDFDFDFDFDULL,
1369 0xFDFDFDFDFDFDFDFDULL,
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0x00FDFDFDFDFDFDFDULL
1376 },
1377 {
1378 0xFDFDFDFDFDFDFDFDULL,
1379 0xFDFDFDFDFDFDFDFDULL,
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL
1386 }
1387 },
1388 {
1389 {
1390 0x0000000000000000ULL,
1391 0x0000000000000000ULL,
1392 0x0000000000000000ULL,
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL
1398 },
1399 {
1400 0x0000000000000000ULL,
1401 0x0000000000000000ULL,
1402 0x0000000000000000ULL,
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0xFD00000000000000ULL
1408 },
1409 {
1410 0x0000000000000000ULL,
1411 0x0000000000000000ULL,
1412 0x0000000000000000ULL,
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0xFD00000000000000ULL,
1417 0xFDFD000000000000ULL
1418 },
1419 {
1420 0x0000000000000000ULL,
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0xFD00000000000000ULL,
1426 0xFDFD000000000000ULL,
1427 0xFDFDFD0000000000ULL
1428 },
1429 {
1430 0x0000000000000000ULL,
1431 0x0000000000000000ULL,
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0xFD00000000000000ULL,
1435 0xFDFD000000000000ULL,
1436 0xFDFDFD0000000000ULL,
1437 0xFDFDFDFD00000000ULL
1438 },
1439 {
1440 0x0000000000000000ULL,
1441 0x0000000000000000ULL,
1442 0x0000000000000000ULL,
1443 0xFD00000000000000ULL,
1444 0xFDFD000000000000ULL,
1445 0xFDFDFD0000000000ULL,
1446 0xFDFDFDFD00000000ULL,
1447 0xFDFDFDFDFD000000ULL
1448 },
1449 {
1450 0x0000000000000000ULL,
1451 0x0000000000000000ULL,
1452 0xFD00000000000000ULL,
1453 0xFDFD000000000000ULL,
1454 0xFDFDFD0000000000ULL,
1455 0xFDFDFDFD00000000ULL,
1456 0xFDFDFDFDFD000000ULL,
1457 0xFDFDFDFDFDFD0000ULL
1458 },
1459 {
1460 0x0000000000000000ULL,
1461 0xFD00000000000000ULL,
1462 0xFDFD000000000000ULL,
1463 0xFDFDFD0000000000ULL,
1464 0xFDFDFDFD00000000ULL,
1465 0xFDFDFDFDFD000000ULL,
1466 0xFDFDFDFDFDFD0000ULL,
1467 0xFDFDFDFDFDFDFD00ULL
1468 },
1469 {
1470 0xFD00000000000000ULL,
1471 0xFDFD000000000000ULL,
1472 0xFDFDFD0000000000ULL,
1473 0xFDFDFDFD00000000ULL,
1474 0xFDFDFDFDFD000000ULL,
1475 0xFDFDFDFDFDFD0000ULL,
1476 0xFDFDFDFDFDFDFD00ULL,
1477 0xFDFDFDFDFDFDFDFDULL
1478 },
1479 {
1480 0xFDFD000000000000ULL,
1481 0xFDFDFD0000000000ULL,
1482 0xFDFDFDFD00000000ULL,
1483 0xFDFDFDFDFD000000ULL,
1484 0xFDFDFDFDFDFD0000ULL,
1485 0xFDFDFDFDFDFDFD00ULL,
1486 0xFDFDFDFDFDFDFDFDULL,
1487 0xFDFDFDFDFDFDFDFDULL
1488 },
1489 {
1490 0xFDFDFD0000000000ULL,
1491 0xFDFDFDFD00000000ULL,
1492 0xFDFDFDFDFD000000ULL,
1493 0xFDFDFDFDFDFD0000ULL,
1494 0xFDFDFDFDFDFDFD00ULL,
1495 0xFDFDFDFDFDFDFDFDULL,
1496 0xFDFDFDFDFDFDFDFDULL,
1497 0xFDFDFDFDFDFDFDFDULL
1498 },
1499 {
1500 0xFDFDFDFD00000000ULL,
1501 0xFDFDFDFDFD000000ULL,
1502 0xFDFDFDFDFDFD0000ULL,
1503 0xFDFDFDFDFDFDFD00ULL,
1504 0xFDFDFDFDFDFDFDFDULL,
1505 0xFDFDFDFDFDFDFDFDULL,
1506 0xFDFDFDFDFDFDFDFDULL,
1507 0xFDFDFDFDFDFDFDFDULL
1508 },
1509 {
1510 0xFDFDFDFDFD000000ULL,
1511 0xFDFDFDFDFDFD0000ULL,
1512 0xFDFDFDFDFDFDFD00ULL,
1513 0xFDFDFDFDFDFDFDFDULL,
1514 0xFDFDFDFDFDFDFDFDULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL
1518 },
1519 {
1520 0xFDFDFDFDFDFD0000ULL,
1521 0xFDFDFDFDFDFDFD00ULL,
1522 0xFDFDFDFDFDFDFDFDULL,
1523 0xFDFDFDFDFDFDFDFDULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL
1528 },
1529 {
1530 0xFDFDFDFDFDFDFD00ULL,
1531 0xFDFDFDFDFDFDFDFDULL,
1532 0xFDFDFDFDFDFDFDFDULL,
1533 0xFDFDFDFDFDFDFDFDULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL
1538 },
1539 {
1540 0xFDFDFDFDFDFDFDFDULL,
1541 0xFDFDFDFDFDFDFDFDULL,
1542 0xFDFDFDFDFDFDFDFDULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL
1548 }
1549 },
1550 {
1551 {
1552 0x0000000000000000ULL,
1553 0x0000000000000000ULL,
1554 0x0000000000000000ULL,
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL
1560 },
1561 {
1562 0x0000000000000000ULL,
1563 0x0000000000000000ULL,
1564 0x0000000000000000ULL,
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x00000000000000FDULL
1570 },
1571 {
1572 0x0000000000000000ULL,
1573 0x0000000000000000ULL,
1574 0x0000000000000000ULL,
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x00000000000000FDULL,
1579 0x000000000000FDFDULL
1580 },
1581 {
1582 0x0000000000000000ULL,
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x00000000000000FDULL,
1588 0x000000000000FDFDULL,
1589 0x0000000000FDFDFDULL
1590 },
1591 {
1592 0x0000000000000000ULL,
1593 0x0000000000000000ULL,
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x00000000000000FDULL,
1597 0x000000000000FDFDULL,
1598 0x0000000000FDFDFDULL,
1599 0x00000000FDFDFDFDULL
1600 },
1601 {
1602 0x0000000000000000ULL,
1603 0x0000000000000000ULL,
1604 0x0000000000000000ULL,
1605 0x00000000000000FDULL,
1606 0x000000000000FDFDULL,
1607 0x0000000000FDFDFDULL,
1608 0x00000000FDFDFDFDULL,
1609 0x000000FDFDFDFDFDULL
1610 },
1611 {
1612 0x0000000000000000ULL,
1613 0x0000000000000000ULL,
1614 0x00000000000000FDULL,
1615 0x000000000000FDFDULL,
1616 0x0000000000FDFDFDULL,
1617 0x00000000FDFDFDFDULL,
1618 0x000000FDFDFDFDFDULL,
1619 0x0000FDFDFDFDFDFDULL
1620 },
1621 {
1622 0x0000000000000000ULL,
1623 0x00000000000000FDULL,
1624 0x000000000000FDFDULL,
1625 0x0000000000FDFDFDULL,
1626 0x00000000FDFDFDFDULL,
1627 0x000000FDFDFDFDFDULL,
1628 0x0000FDFDFDFDFDFDULL,
1629 0x00FDFDFDFDFDFDFDULL
1630 },
1631 {
1632 0x00000000000000FDULL,
1633 0x000000000000FDFDULL,
1634 0x0000000000FDFDFDULL,
1635 0x00000000FDFDFDFDULL,
1636 0x000000FDFDFDFDFDULL,
1637 0x0000FDFDFDFDFDFDULL,
1638 0x00FDFDFDFDFDFDFDULL,
1639 0xFDFDFDFDFDFDFDFDULL
1640 },
1641 {
1642 0x000000000000FDFDULL,
1643 0x0000000000FDFDFDULL,
1644 0x00000000FDFDFDFDULL,
1645 0x000000FDFDFDFDFDULL,
1646 0x0000FDFDFDFDFDFDULL,
1647 0x00FDFDFDFDFDFDFDULL,
1648 0xFDFDFDFDFDFDFDFDULL,
1649 0xFDFDFDFDFDFDFDFDULL
1650 },
1651 {
1652 0x0000000000FDFDFDULL,
1653 0x00000000FDFDFDFDULL,
1654 0x000000FDFDFDFDFDULL,
1655 0x0000FDFDFDFDFDFDULL,
1656 0x00FDFDFDFDFDFDFDULL,
1657 0xFDFDFDFDFDFDFDFDULL,
1658 0xFDFDFDFDFDFDFDFDULL,
1659 0xFDFDFDFDFDFDFDFDULL
1660 },
1661 {
1662 0x00000000FDFDFDFDULL,
1663 0x000000FDFDFDFDFDULL,
1664 0x0000FDFDFDFDFDFDULL,
1665 0x00FDFDFDFDFDFDFDULL,
1666 0xFDFDFDFDFDFDFDFDULL,
1667 0xFDFDFDFDFDFDFDFDULL,
1668 0xFDFDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL
1670 },
1671 {
1672 0x000000FDFDFDFDFDULL,
1673 0x0000FDFDFDFDFDFDULL,
1674 0x00FDFDFDFDFDFDFDULL,
1675 0xFDFDFDFDFDFDFDFDULL,
1676 0xFDFDFDFDFDFDFDFDULL,
1677 0xFDFDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL
1680 },
1681 {
1682 0x0000FDFDFDFDFDFDULL,
1683 0x00FDFDFDFDFDFDFDULL,
1684 0xFDFDFDFDFDFDFDFDULL,
1685 0xFDFDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL
1690 },
1691 {
1692 0x00FDFDFDFDFDFDFDULL,
1693 0xFDFDFDFDFDFDFDFDULL,
1694 0xFDFDFDFDFDFDFDFDULL,
1695 0xFDFDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL
1700 },
1701 {
1702 0xFDFDFDFDFDFDFDFDULL,
1703 0xFDFDFDFDFDFDFDFDULL,
1704 0xFDFDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL
1710 }
1711 }
1712 };
1713
1714 int32_t black_opening_count=0;
1715 int32_t black_opening_x,black_opening_y;
1716 int32_t black_opening_shape;
1717
1718 791 int32_t choose_opening_shape()
1719 {
1720 // First, count how many bits are set
1721 791 int32_t numBits=0;
1722 int32_t bitCounter;
1723
1724
2/2
✓ Branch 0 taken 3955 times.
✓ Branch 1 taken 791 times.
4746 for(int32_t i=0; i<bosMAX; i++)
1725 {
1726
2/2
✓ Branch 0 taken 2948 times.
✓ Branch 1 taken 1007 times.
3955 if(COOLSCROLL&(1<<i))
1727 1007 numBits++;
1728 3955 }
1729
1730 // Shouldn't happen...
1731
1/2
✓ Branch 0 taken 791 times.
✗ Branch 1 not taken.
791 if(numBits==0)
1732 return bosCIRCLE;
1733
1734 // Pick a bit
1735 791 bitCounter=zc_rand()%numBits+1;
1736
1737
2/2
✓ Branch 0 taken 1003 times.
✓ Branch 1 taken 26 times.
1029 for(int32_t i=0; i<bosMAX; i++)
1738 {
1739 // If this bit is set, decrement the bit counter
1740
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 921 times.
1003 if(COOLSCROLL&(1<<i))
1741 921 bitCounter--;
1742
1743 // When the counter hits 0, return a value based on
1744 // which bit it stopped on.
1745 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1746
2/2
✓ Branch 0 taken 765 times.
✓ Branch 1 taken 238 times.
1003 if(bitCounter==0)
1747 765 return i;
1748 238 }
1749
1750 // Shouldn't be necessary, but the compiler might complain, at least
1751 26 return bosCIRCLE;
1752 791 }
1753
1754 216 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1755 {
1756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1757
1758 216 int32_t w=256, h=224;
1759 216 int32_t blockrows=28, blockcolumns=32;
1760 216 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1761
1762
2/2
✓ Branch 0 taken 6048 times.
✓ Branch 1 taken 216 times.
6264 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1763 {
1764
2/2
✓ Branch 0 taken 193536 times.
✓ Branch 1 taken 6048 times.
199584 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1765 {
1766
2/2
✓ Branch 0 taken 103944 times.
✓ Branch 1 taken 89592 times.
193536 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1767 193536 }
1768 6048 }
1769
1770 216 black_opening_count = 66;
1771 216 black_opening_x = x;
1772 216 black_opening_y = y;
1773 216 lensclk = 0;
1774 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1775
1776
1777
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(black_opening_shape == bosFADEBLACK)
1778 {
1779 refreshTints();
1780 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1781 }
1782
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(wait)
1783 {
1784 FFCore.warpScriptCheck();
1785 for(int32_t i=0; i<66; i++)
1786 {
1787 draw_screen(tmpscr);
1788 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1789 advanceframe(true);
1790
1791 if(Quit)
1792 {
1793 break;
1794 }
1795 }
1796 }
1797 216 }
1798
1799 575 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1800 {
1801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1802
1803 575 int32_t w=256, h=224;
1804 575 int32_t blockrows=28, blockcolumns=32;
1805 575 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1806
1807
2/2
✓ Branch 0 taken 16100 times.
✓ Branch 1 taken 575 times.
16675 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1808 {
1809
2/2
✓ Branch 0 taken 515200 times.
✓ Branch 1 taken 16100 times.
531300 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1810 {
1811
2/2
✓ Branch 0 taken 241603 times.
✓ Branch 1 taken 273597 times.
515200 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1812 515200 }
1813 16100 }
1814
1815 575 black_opening_count = -66;
1816 575 black_opening_x = x;
1817 575 black_opening_y = y;
1818 575 lensclk = 0;
1819
1/2
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
575 if(black_opening_shape == bosFADEBLACK)
1820 {
1821 refreshTints();
1822 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1823 }
1824
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 465 times.
575 if(wait)
1825 {
1826 465 FFCore.warpScriptCheck();
1827
2/2
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 30690 times.
31155 for(int32_t i=0; i<66; i++)
1828 {
1829 30690 draw_screen(tmpscr);
1830 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1831 30690 advanceframe(true);
1832
1833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30690 times.
30690 if(Quit)
1834 {
1835 break;
1836 }
1837 30690 }
1838 465 }
1839 575 }
1840
1841 52206 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1842 {
1843 52206 clear_to_color(tmp_scr,BLACK);
1844 52206 int32_t w=256, h=224;
1845
1846
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 1650 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 49038 times.
52206 switch(black_opening_shape)
1847 {
1848 case bosOVAL:
1849 {
1850 858 double new_w=(w/2)+abs(w/2-x);
1851 858 double new_h=(h/2)+abs(h/2-y);
1852 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1853 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1854 858 break;
1855 }
1856
1857 case bosTRIANGLE:
1858 {
1859 660 double new_w=(w/2)+abs(w/2-x);
1860 660 double new_h=(h/2)+abs(h/2-y);
1861 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1862 660 double P2= (PI/2);
1863 660 double P23=(2*PI/3);
1864 660 double P43=(4*PI/3);
1865 660 double Pa= (-4*PI*a/(3*max_a));
1866 660 double angle=P2+Pa;
1867 660 double a0=angle;
1868 660 double a2=angle+P23;
1869 660 double a4=angle+P43;
1870 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1871 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1872 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1873 0);
1874 660 break;
1875 }
1876
1877 case bosSMAS:
1878 {
1879
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 990 times.
1650 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1880
1881
2/2
✓ Branch 0 taken 46200 times.
✓ Branch 1 taken 1650 times.
47850 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1882 {
1883
2/2
✓ Branch 0 taken 369600 times.
✓ Branch 1 taken 46200 times.
415800 for(int32_t linerow=0; linerow<8; ++linerow)
1884 {
1885 369600 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1886
1887
2/2
✓ Branch 0 taken 11827200 times.
✓ Branch 1 taken 369600 times.
12196800 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1888 {
1889 35481600 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1890
6/6
✓ Branch 0 taken 8249728 times.
✓ Branch 1 taken 3577472 times.
✓ Branch 2 taken 7829672 times.
✓ Branch 3 taken 3997528 times.
✓ Branch 4 taken 4252200 times.
✓ Branch 5 taken 3577472 times.
11827200 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1891 11827200 [linerow];
1892 11827200 ++triangleline;
1893
1894
2/2
✓ Branch 0 taken 10348800 times.
✓ Branch 1 taken 1478400 times.
11827200 if(linerow==0)
1895 {
1896 1478400 }
1897 11827200 }
1898 369600 }
1899 46200 }
1900
1901 1650 break;
1902 }
1903
1904 case bosFADEBLACK:
1905 {
1906 if(black_opening_count<0)
1907 {
1908 black_fade(zc_min(-black_opening_count,63));
1909 }
1910 else if(black_opening_count>0)
1911 {
1912 black_fade(63-zc_max(black_opening_count-3,0));
1913 }
1914 else black_fade(0);
1915 return; //no blitting from tmp_scr!
1916 }
1917
1918 49038 case bosCIRCLE:
1919 default:
1920 {
1921 49038 double new_w=(w/2)+abs(w/2-x);
1922 49038 double new_h=(h/2)+abs(h/2-y);
1923 49038 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1924 //circlefill(tmp_scr,x,y,a<<3,0);
1925 49038 circlefill(tmp_scr,x,y,r,0);
1926 49038 break;
1927 }
1928 }
1929
1930 52206 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1931 52206 }
1932
1933
1934 void black_fade(int32_t fadeamnt)
1935 {
1936 for(int32_t i=0; i < 0xEF; i++)
1937 {
1938 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1939 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1940 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1941 }
1942
1943 refreshpal = true;
1944 }
1945
1946 //----------------------------------------------------------------
1947
1948 15952490 bool item_disabled(int32_t item) //is this item disabled?
1949 {
1950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15952490 times.
15952490 return (item>=0 && game->items_off[item] != 0);
1951 }
1952
1953 5426600 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1954 {
1955
2/2
✓ Branch 0 taken 57842 times.
✓ Branch 1 taken 5368758 times.
5426600 if(current_item(item_type, true) >=item)
1956 {
1957 57842 return true;
1958 }
1959
1960 5368758 return false;
1961 5426600 }
1962
1963 22449319 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1964 {
1965
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4086346 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2439977 times.
✓ Branch 6 taken 12012783 times.
✓ Branch 7 taken 3882589 times.
✓ Branch 8 taken 27624 times.
22449319 switch(item_type)
1966 {
1967 case itype_bomb:
1968 case itype_sbomb:
1969 {
1970 int32_t itemid = getItemID(itemsbuf, item_type, it);
1971
1972 if(itemid == -1)
1973 return false;
1974
1975 return (game->get_item(itemid));
1976 }
1977
1978 case itype_clock:
1979 {
1980 4086346 int32_t itemid = getItemID(itemsbuf, item_type, it);
1981
1982
2/4
✓ Branch 0 taken 4086346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4086346 times.
✗ Branch 3 not taken.
4086346 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1983 return (game->get_item(itemid));
1984 4086346 return Hero.getClock()?1:0;
1985 }
1986
1987 case itype_key:
1988 return (game->get_keys()>0);
1989
1990 case itype_magiccontainer:
1991 return (game->get_maxmagic()>=game->get_mp_per_block());
1992
1993 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1994 {
1995
1/3
✓ Branch 0 taken 2439977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2439977 switch(it)
1996 {
1997 case -2:
1998 {
1999 for(int32_t i=0; i<MAXLEVELS; i++)
2000 {
2001 if(game->lvlitems[i]&liTRIFORCE)
2002 {
2003 return true;
2004 }
2005 }
2006
2007 return false;
2008 }
2009
2010 case -1:
2011 return (game->lvlitems[dlevel]&liTRIFORCE);
2012
2013 default:
2014
2/4
✓ Branch 0 taken 2439977 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2439977 times.
2439977 if(it>=0&&it<MAXLEVELS)
2015 {
2016 2439977 return (game->lvlitems[it]&liTRIFORCE);
2017 }
2018
2019 break;
2020 }
2021
2022 return 0;
2023 }
2024
2025 case itype_map: //it: -2=any, -1=current level, other=that level
2026 {
2027
1/3
✓ Branch 0 taken 12012783 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12012783 switch(it)
2028 {
2029 case -2:
2030 {
2031 for(int32_t i=0; i<MAXLEVELS; i++)
2032 {
2033 if(game->lvlitems[i]&liMAP)
2034 {
2035 return true;
2036 }
2037 }
2038
2039 return false;
2040 }
2041
2042 case -1:
2043 return (game->lvlitems[dlevel]&liMAP)!=0;
2044
2045 default:
2046
2/4
✓ Branch 0 taken 12012783 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12012783 times.
12012783 if(it>=0&&it<MAXLEVELS)
2047 {
2048 12012783 return (game->lvlitems[it]&liMAP)!=0;
2049 }
2050
2051 break;
2052 }
2053
2054 return 0;
2055 }
2056
2057 case itype_compass: //it: -2=any, -1=current level, other=that level
2058 {
2059
1/3
✓ Branch 0 taken 3882589 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3882589 switch(it)
2060 {
2061 case -2:
2062 {
2063 for(int32_t i=0; i<MAXLEVELS; i++)
2064 {
2065 if(game->lvlitems[i]&liCOMPASS)
2066 {
2067 return true;
2068 }
2069 }
2070
2071 return false;
2072 }
2073
2074 case -1:
2075 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2076
2077 default:
2078
2/4
✓ Branch 0 taken 3882589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3882589 times.
✗ Branch 3 not taken.
3882589 if(it>=0&&it<MAXLEVELS)
2079 {
2080 3882589 return (game->lvlitems[it]&liCOMPASS)!=0;
2081 }
2082
2083 break;
2084 }
2085 return 0;
2086 }
2087
2088 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2089 {
2090
1/3
✓ Branch 0 taken 27624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
27624 switch(it)
2091 {
2092 case -2:
2093 {
2094 for(int32_t i=0; i<MAXLEVELS; i++)
2095 {
2096 if(game->lvlitems[i]&liBOSSKEY)
2097 {
2098 return true;
2099 }
2100 }
2101
2102 return false;
2103 }
2104
2105 case -1:
2106 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2107
2108 default:
2109
2/4
✓ Branch 0 taken 27624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27624 times.
27624 if(it>=0&&it<MAXLEVELS)
2110 {
2111 27624 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2112 }
2113 break;
2114 }
2115 return 0;
2116 }
2117
2118 default:
2119 //it=(1<<(it-1));
2120 /*if (item_type>=itype_max)
2121 {
2122 system_pal();
2123 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2124 game_pal();
2125
2126 return false;
2127 }*/
2128 int32_t itemid = getItemID(itemsbuf, item_type, it);
2129
2130 if(itemid == -1)
2131 return false;
2132
2133 return game->get_item(itemid);
2134 }
2135 22449319 }
2136
2137
2138 69865212 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2139 {
2140
9/9
✓ Branch 0 taken 4086346 times.
✓ Branch 1 taken 37174444 times.
✓ Branch 2 taken 4086346 times.
✓ Branch 3 taken 4086346 times.
✓ Branch 4 taken 4086346 times.
✓ Branch 5 taken 4086346 times.
✓ Branch 6 taken 4086346 times.
✓ Branch 7 taken 4086346 times.
✓ Branch 8 taken 4086346 times.
69865212 switch(item_type)
2141 {
2142 case itype_clock:
2143 {
2144 4086346 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2145
2146
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4086346 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4086346 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2147 return itemsbuf[maxid].fam_type;
2148
2149 4086346 return has_item(itype_clock,1) ? 1 : 0;
2150 }
2151
2152 case itype_key:
2153 4086346 return game->get_keys();
2154
2155 case itype_lkey:
2156 4086346 return game->lvlkeys[get_dlevel()];
2157
2158 case itype_magiccontainer:
2159 4086346 return game->get_maxmagic()/game->get_mp_per_block();
2160
2161 case itype_triforcepiece:
2162 {
2163 4086346 int32_t count=0;
2164
2165
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2166 {
2167 2092209152 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2168 2092209152 }
2169
2170 4086346 return count;
2171 }
2172
2173 case itype_map:
2174 {
2175 4086346 int32_t count=0;
2176
2177
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2178 {
2179 2092209152 count+=(game->lvlitems[i]&liMAP)?1:0;
2180 2092209152 }
2181
2182 4086346 return count;
2183 }
2184
2185 case itype_compass:
2186 {
2187 4086346 int32_t count=0;
2188
2189
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2190 {
2191 2092209152 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2192 2092209152 }
2193
2194 4086346 return count;
2195 }
2196
2197 case itype_bosskey:
2198 {
2199 4086346 int32_t count=0;
2200
2201
2/2
✓ Branch 0 taken 2092209152 times.
✓ Branch 1 taken 4086346 times.
2096295498 for(int32_t i=0; i<MAXLEVELS; i++)
2202 {
2203 2092209152 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2204 2092209152 }
2205
2206 4086346 return count;
2207 }
2208
2209 default:
2210 37174444 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2211
2212
2/2
✓ Branch 0 taken 6971052 times.
✓ Branch 1 taken 30203392 times.
37174444 if(maxid == -1)
2213 30203392 return 0;
2214
2215 6971052 return itemsbuf[maxid].fam_type;
2216 }
2217 69865212 }
2218
2219 64438612 int32_t current_item(int32_t item_type) //item currently being used
2220 {
2221 64438612 return current_item(item_type, true);
2222 }
2223
2224 29 std::map<int32_t, int32_t> itemcache;
2225
2226 // Not actually used by anything at the moment...
2227 void removeFromItemCache(int32_t itemid)
2228 {
2229 itemcache.erase(itemid);
2230 }
2231
2232 19096 void flushItemCache()
2233 {
2234 19096 itemcache.clear();
2235
2236 //also fix the active subscreen if items were deleted -DD
2237
1/2
✓ Branch 0 taken 19096 times.
✗ Branch 1 not taken.
19096 if(game != NULL)
2238 {
2239 19096 verifyBothWeapons();
2240 19096 load_Sitems(&QMisc);
2241 19096 }
2242 19096 }
2243
2244 // This is used often, so it should be as direct as possible.
2245 2281813085 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2246 {
2247
2/2
✓ Branch 0 taken 2233008728 times.
✓ Branch 1 taken 48804357 times.
2281813085 if(jinx_check)
2248 {
2249
4/4
✓ Branch 0 taken 31164925 times.
✓ Branch 1 taken 17639432 times.
✓ Branch 2 taken 27758483 times.
✓ Branch 3 taken 3406442 times.
48804357 if(!(HeroSwordClk() || HeroItemClk()))
2250 27758483 jinx_check = false; //not jinxed
2251 48804357 }
2252
4/4
✓ Branch 0 taken 2262409545 times.
✓ Branch 1 taken 19403540 times.
✓ Branch 2 taken 20897290 times.
✓ Branch 3 taken 2241512255 times.
2281813085 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2253 {
2254 2241512255 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2255
2256
2/2
✓ Branch 0 taken 2231763743 times.
✓ Branch 1 taken 9748512 times.
2241512255 if(res != itemcache.end())
2257 2231763743 return res->second;
2258 9748512 }
2259
2260 50049342 int32_t result = -1;
2261 50049342 int32_t highestlevel = -1;
2262
2263
2/2
✓ Branch 0 taken 12812631552 times.
✓ Branch 1 taken 50049342 times.
12862680894 for(int32_t i=0; i<MAXITEMS; i++)
2264 {
2265
5/6
✓ Branch 0 taken 1030627526 times.
✓ Branch 1 taken 11782004026 times.
✓ Branch 2 taken 15409861 times.
✓ Branch 3 taken 1015217665 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15409861 times.
12812631552 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2266 {
2267
4/4
✓ Branch 0 taken 4655389 times.
✓ Branch 1 taken 10754472 times.
✓ Branch 2 taken 1195206 times.
✓ Branch 3 taken 14214655 times.
15409861 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2268 {
2269 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2270
2/2
✓ Branch 0 taken 14214535 times.
✓ Branch 1 taken 120 times.
14214655 if(!checkmagiccost(i))
2271 {
2272
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 108 times.
120 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2273 12 }
2274 14214547 }
2275
6/6
✓ Branch 0 taken 13234243 times.
✓ Branch 1 taken 2175510 times.
✓ Branch 2 taken 229100 times.
✓ Branch 3 taken 1946410 times.
✓ Branch 4 taken 1458492 times.
✓ Branch 5 taken 717018 times.
15409753 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2276 {
2277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 717018 times.
717018 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2278 717018 continue;
2279 }
2280
2281
2/2
✓ Branch 0 taken 223586 times.
✓ Branch 1 taken 14469149 times.
14692735 if(itemsbuf[i].fam_type >= highestlevel)
2282 {
2283 14469149 highestlevel = itemsbuf[i].fam_type;
2284 14469149 result=i;
2285 14469149 }
2286 14692735 }
2287 12811914426 }
2288
2289
2/2
✓ Branch 0 taken 21045874 times.
✓ Branch 1 taken 29003468 times.
50049342 if(!jinx_check) //Can't cache jinx_check results
2290 29003468 itemcache[itemtype] = result;
2291 50049342 return result;
2292 2281813085 }
2293
2294 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2295 2261047794 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2296 {
2297 2261047794 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2298
2/2
✓ Branch 0 taken 28039066 times.
✓ Branch 1 taken 2233008728 times.
2261047794 if(!jinx_check) //If not already a jinx-immune-only check...
2299 {
2300 //And the player IS jinxed...
2301
4/4
✓ Branch 0 taken 2215600801 times.
✓ Branch 1 taken 17407927 times.
✓ Branch 2 taken 3357364 times.
✓ Branch 3 taken 2212243437 times.
2233008728 if(HeroSwordClk() || HeroItemClk())
2302 {
2303 //Then do a jinx-immune-only check here
2304 20765291 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2305 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2306 //Should NOT need a compat rule, as this should always return -1 in old quests.
2307
2/2
✓ Branch 0 taken 974915 times.
✓ Branch 1 taken 19790376 times.
20765291 if(ret2 > -1) return ret2;
2308 19790376 }
2309 2232033813 }
2310 2260072879 return ret;
2311 2261047794 }
2312 14776608 int32_t current_item_power(int32_t itemtype)
2313 {
2314 14776608 int32_t result = current_item_id(itemtype,true);
2315
2/2
✓ Branch 0 taken 11445380 times.
✓ Branch 1 taken 3331228 times.
14776608 return (result<0) ? 0 : itemsbuf[result].power;
2316 }
2317
2318 7 int32_t heart_container_id()
2319 {
2320
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 for(int32_t i=0; i<MAXITEMS; i++)
2321 {
2322
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 196 times.
203 if(itemsbuf[i].family == itype_heartcontainer)
2323 {
2324 7 return i;
2325 }
2326 196 }
2327 return -1;
2328 7 }
2329
2330 4086346 int32_t item_tile_mod()
2331 {
2332 4086346 int32_t tile=0;
2333
2334
2/2
✓ Branch 0 taken 975760 times.
✓ Branch 1 taken 3110586 times.
4086346 if(game->get_bombs())
2335 {
2336 3110586 int32_t itemid = current_item_id(itype_bomb,false);
2337
3/4
✓ Branch 0 taken 3029527 times.
✓ Branch 1 taken 81059 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3029527 times.
3110586 if(itemid > -1 && checkbunny(itemid))
2338 3029527 tile+=itemsbuf[itemid].ltm;
2339 3110586 }
2340
2341
2/2
✓ Branch 0 taken 3032663 times.
✓ Branch 1 taken 1053683 times.
4086346 if(game->get_sbombs())
2342 {
2343 1053683 int32_t itemid = current_item_id(itype_sbomb,false);
2344
3/4
✓ Branch 0 taken 1052255 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1052255 times.
1053683 if(itemid > -1 && checkbunny(itemid))
2345 1052255 tile+=itemsbuf[itemid].ltm;
2346 1053683 }
2347
2348
2/2
✓ Branch 0 taken 3998396 times.
✓ Branch 1 taken 87950 times.
4086346 if(current_item(itype_clock))
2349 {
2350 87950 int32_t itemid =
2351
1/2
✓ Branch 0 taken 87950 times.
✗ Branch 1 not taken.
87950 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2352 ? iClock
2353 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2354
2/4
✓ Branch 0 taken 87950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 87950 times.
87950 if(itemid > -1 && checkbunny(itemid))
2355 87950 tile+=itemsbuf[itemid].ltm;
2356 87950 }
2357
2358
2/2
✓ Branch 0 taken 3438526 times.
✓ Branch 1 taken 647820 times.
4086346 if(current_item(itype_key))
2359 {
2360 647820 int32_t itemid =
2361
1/2
✓ Branch 0 taken 647820 times.
✗ Branch 1 not taken.
647820 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2362 ? iKey
2363 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2364
2/4
✓ Branch 0 taken 647820 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 647820 times.
647820 if(itemid > -1 && checkbunny(itemid))
2365 647820 tile+=itemsbuf[itemid].ltm;
2366 647820 }
2367
2368
2/2
✓ Branch 0 taken 3927093 times.
✓ Branch 1 taken 159253 times.
4086346 if(current_item(itype_lkey))
2369 {
2370 159253 int32_t itemid =
2371
2/2
✓ Branch 0 taken 158343 times.
✓ Branch 1 taken 910 times.
159253 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2372 ? iLevelKey
2373 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2374
2/4
✓ Branch 0 taken 159253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159253 times.
159253 if(itemid > -1 && checkbunny(itemid))
2375 159253 tile+=itemsbuf[itemid].ltm;
2376 159253 }
2377
2378
2/2
✓ Branch 0 taken 886117 times.
✓ Branch 1 taken 3200229 times.
4086346 if(current_item(itype_map))
2379 {
2380 3200229 int32_t itemid =
2381
2/2
✓ Branch 0 taken 3199443 times.
✓ Branch 1 taken 786 times.
3200229 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2382 ? iMap
2383 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2384
2/4
✓ Branch 0 taken 3200229 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3200229 times.
3200229 if(itemid > -1 && checkbunny(itemid))
2385 3200229 tile+=itemsbuf[itemid].ltm;
2386 3200229 }
2387
2388
2/2
✓ Branch 0 taken 807819 times.
✓ Branch 1 taken 3278527 times.
4086346 if(current_item(itype_compass))
2389 {
2390 3278527 int32_t itemid =
2391
2/2
✓ Branch 0 taken 3197468 times.
✓ Branch 1 taken 81059 times.
3278527 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2392 ? iCompass
2393 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2394
2/4
✓ Branch 0 taken 3278527 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3278527 times.
3278527 if(itemid > -1 && checkbunny(itemid))
2395 3278527 tile+=itemsbuf[itemid].ltm;
2396 3278527 }
2397
2398
2/2
✓ Branch 0 taken 2275984 times.
✓ Branch 1 taken 1810362 times.
4086346 if(current_item(itype_bosskey))
2399 {
2400 1810362 int32_t itemid =
2401
1/2
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
1810362 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2402 ? iBossKey
2403 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2404
2/4
✓ Branch 0 taken 1810362 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1810362 times.
1810362 if(itemid > -1 && checkbunny(itemid))
2405 1810362 tile+=itemsbuf[itemid].ltm;
2406 1810362 }
2407
2408
2/2
✓ Branch 0 taken 2141126 times.
✓ Branch 1 taken 1945220 times.
4086346 if(current_item(itype_magiccontainer))
2409 {
2410 1945220 int32_t itemid =
2411
2/2
✓ Branch 0 taken 1852005 times.
✓ Branch 1 taken 93215 times.
1945220 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2412 ? iMagicC
2413 93215 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2414
3/4
✓ Branch 0 taken 1945220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 1943350 times.
1945220 if(itemid > -1 && checkbunny(itemid))
2415 1943350 tile+=itemsbuf[itemid].ltm;
2416 1945220 }
2417
2418
2/2
✓ Branch 0 taken 1118041 times.
✓ Branch 1 taken 2968305 times.
4086346 if(current_item(itype_triforcepiece))
2419 {
2420 2968305 int32_t itemid =
2421
1/2
✓ Branch 0 taken 2968305 times.
✗ Branch 1 not taken.
2968305 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2422 ? iTriforce
2423 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2424
2/4
✓ Branch 0 taken 2968305 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2968305 times.
2968305 if(itemid > -1 && checkbunny(itemid))
2425 2968305 tile+=itemsbuf[itemid].ltm;
2426 2968305 }
2427
2428
2/2
✓ Branch 0 taken 4086346 times.
✓ Branch 1 taken 2092209152 times.
2096295498 for(int32_t i=0; i<itype_max; i++)
2429 {
2430
2/2
✓ Branch 0 taken 2035907072 times.
✓ Branch 1 taken 56302080 times.
2092209152 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2431 {
2432
2/2
✓ Branch 0 taken 1099650 times.
✓ Branch 1 taken 55202430 times.
56302080 switch(i)
2433 {
2434 case itype_bomb:
2435 case itype_sbomb:
2436 case itype_clock:
2437 case itype_key:
2438 case itype_lkey:
2439 case itype_map:
2440 case itype_compass:
2441 case itype_bosskey:
2442 case itype_magiccontainer:
2443 case itype_triforcepiece:
2444 1099650 continue; //already handled
2445 }
2446 55202430 }
2447 2091109502 int32_t itemid = current_item_id(i,false);
2448
2/2
✓ Branch 0 taken 2087023156 times.
✓ Branch 1 taken 4086346 times.
2091109502 if(i == itype_shield)
2449 4086346 itemid = getCurrentShield(false);
2450
2451
4/4
✓ Branch 0 taken 59139201 times.
✓ Branch 1 taken 2031970301 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 59038220 times.
2091109502 if(itemid < 0 || !checkbunny(itemid))
2452 2032071282 continue;
2453
2454 59038220 itemdata const& itm = itemsbuf[itemid];
2455
2456
2/2
✓ Branch 0 taken 55529396 times.
✓ Branch 1 taken 3508824 times.
59038220 switch(itm.family)
2457 {
2458 case itype_shield:
2459
1/2
✓ Branch 0 taken 3508824 times.
✗ Branch 1 not taken.
3508824 if(itm.flags & ITEM_FLAG9) //active shield
2460 {
2461 if(!usingActiveShield(itemid))
2462 {
2463 tile+=itm.misc6; //'Inactive PTM'
2464 continue;
2465 }
2466 }
2467 3508824 break;
2468 }
2469
2470 59038220 tile+=itm.ltm;
2471 59038220 }
2472
2473 4086346 return tile;
2474 }
2475
2476 4086346 int32_t bunny_tile_mod()
2477 {
2478
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 4084476 times.
4086346 if(Hero.BunnyClock())
2479 {
2480 1870 return game->get_bunny_ltm();
2481 }
2482 4084476 return 0;
2483 4086346 }
2484
2485 // Hints are drawn on a separate layer to combo reveals.
2486 16332 void draw_lens_under(BITMAP *dest, bool layer)
2487 {
2488 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2489 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2490 //Lens flag 3: Don't show armos/chest/dive items
2491 //Lens flag 4: Show Raft Paths
2492 //Lens flag 5: Show Invisible Enemies
2493
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2494
2495 16332 int32_t strike_hint_table[11]=
2496 {
2497 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2498 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2499 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2500 };
2501
2502 // int32_t page = tmpscr->cpage;
2503 {
2504 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2505 // int32_t temptimer=0;
2506 16332 int32_t tempitem, tempweapon=0;
2507 16332 strike_hint=strike_hint_table[strike_hint_counter];
2508
2509
2/2
✓ Branch 0 taken 15840 times.
✓ Branch 1 taken 492 times.
16332 if(strike_hint_timer>32)
2510 {
2511 492 strike_hint_timer=0;
2512 492 strike_hint_counter=((strike_hint_counter+1)%11);
2513 492 }
2514
2515 16332 ++strike_hint_timer;
2516
2517
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2518 {
2519 2874432 int32_t x = (i & 15) << 4;
2520 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2521 2874432 int32_t tempitemx=-16, tempitemy=-16;
2522 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2523
2524
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2525 {
2526 5748864 int32_t checkflag=0;
2527
2528
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2529 {
2530 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2531 2874432 }
2532 else
2533 {
2534 2874432 checkflag=tmpscr->sflag[i];
2535 }
2536
2537
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2538 {
2539
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2540 {
2541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2542 906 }
2543 else
2544 {
2545 192 checkflag = strike_hint;
2546 }
2547 1098 }
2548
2549
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2550 {
2551 case 0:
2552 case mfZELDA:
2553 case mfPUSHED:
2554 case mfENEMY0:
2555 case mfENEMY1:
2556 case mfENEMY2:
2557 case mfENEMY3:
2558 case mfENEMY4:
2559 case mfENEMY5:
2560 case mfENEMY6:
2561 case mfENEMY7:
2562 case mfENEMY8:
2563 case mfENEMY9:
2564 case mfSINGLE:
2565 case mfSINGLE16:
2566 case mfNOENEMY:
2567 case mfTRAP_H:
2568 case mfTRAP_V:
2569 case mfTRAP_4:
2570 case mfTRAP_LR:
2571 case mfTRAP_UD:
2572 case mfNOGROUNDENEMY:
2573 case mfNOBLOCKS:
2574 case mfSCRIPT1:
2575 case mfSCRIPT2:
2576 case mfSCRIPT3:
2577 case mfSCRIPT4:
2578 case mfSCRIPT5:
2579 case mfSCRIPT6:
2580 case mfSCRIPT7:
2581 case mfSCRIPT8:
2582 case mfSCRIPT9:
2583 case mfSCRIPT10:
2584 case mfSCRIPT11:
2585 case mfSCRIPT12:
2586 case mfSCRIPT13:
2587 case mfSCRIPT14:
2588 case mfSCRIPT15:
2589 case mfSCRIPT16:
2590 case mfSCRIPT17:
2591 case mfSCRIPT18:
2592 case mfSCRIPT19:
2593 case mfSCRIPT20:
2594 case mfPITHOLE:
2595 case mfPITFALLFLOOR:
2596 case mfLAVA:
2597 case mfICE:
2598 case mfICEDAMAGE:
2599 case mfDAMAGE1:
2600 case mfDAMAGE2:
2601 case mfDAMAGE4:
2602 case mfDAMAGE8:
2603 case mfDAMAGE16:
2604 case mfDAMAGE32:
2605 case mfFREEZEALL:
2606 case mfFREZEALLANSFFCS:
2607 case mfFREEZEFFCSOLY:
2608 case mfSCRITPTW1TRIG:
2609 case mfSCRITPTW2TRIG:
2610 case mfSCRITPTW3TRIG:
2611 case mfSCRITPTW4TRIG:
2612 case mfSCRITPTW5TRIG:
2613 case mfSCRITPTW6TRIG:
2614 case mfSCRITPTW7TRIG:
2615 case mfSCRITPTW8TRIG:
2616 case mfSCRITPTW9TRIG:
2617 case mfSCRITPTW10TRIG:
2618 case mfTROWEL:
2619 case mfTROWELNEXT:
2620 case mfTROWELSPECIALITEM:
2621 case mfSLASHPOT:
2622 case mfLIFTPOT:
2623 case mfLIFTORSLASH:
2624 case mfLIFTROCK:
2625 case mfLIFTROCKHEAVY:
2626 case mfDROPITEM:
2627 case mfSPECIALITEM:
2628 case mfDROPKEY:
2629 case mfDROPLKEY:
2630 case mfDROPCOMPASS:
2631 case mfDROPMAP:
2632 case mfDROPBOSSKEY:
2633 case mfSPAWNNPC:
2634 case mfSWITCHHOOK:
2635 case mfSIDEVIEWLADDER:
2636 case mfSIDEVIEWPLATFORM:
2637 case mfNOENEMYSPAWN:
2638 case mfENEMYALL:
2639 case mfNOMIRROR:
2640 case mfUNSAFEGROUND:
2641 case mf168:
2642 case mf169:
2643 case mf170:
2644 case mf171:
2645 case mf172:
2646 case mf173:
2647 case mf174:
2648 case mf175:
2649 case mf176:
2650 case mf177:
2651 case mf178:
2652 case mf179:
2653 case mf180:
2654 case mf181:
2655 case mf182:
2656 case mf183:
2657 case mf184:
2658 case mf185:
2659 case mf186:
2660 case mf187:
2661 case mf188:
2662 case mf189:
2663 case mf190:
2664 case mf191:
2665 case mf192:
2666 case mf193:
2667 case mf194:
2668 case mf195:
2669 case mf196:
2670 case mf197:
2671 case mf198:
2672 case mf199:
2673 case mf200:
2674 case mf201:
2675 case mf202:
2676 case mf203:
2677 case mf204:
2678 case mf205:
2679 case mf206:
2680 case mf207:
2681 case mf208:
2682 case mf209:
2683 case mf210:
2684 case mf211:
2685 case mf212:
2686 case mf213:
2687 case mf214:
2688 case mf215:
2689 case mf216:
2690 case mf217:
2691 case mf218:
2692 case mf219:
2693 case mf220:
2694 case mf221:
2695 case mf222:
2696 case mf223:
2697 case mf224:
2698 case mf225:
2699 case mf226:
2700 case mf227:
2701 case mf228:
2702 case mf229:
2703 case mf230:
2704 case mf231:
2705 case mf232:
2706 case mf233:
2707 case mf234:
2708 case mf235:
2709 case mf236:
2710 case mf237:
2711 case mf238:
2712 case mf239:
2713 case mf240:
2714 case mf241:
2715 case mf242:
2716 case mf243:
2717 case mf244:
2718 case mf245:
2719 case mf246:
2720 case mf247:
2721 case mf248:
2722 case mf249:
2723 case mf250:
2724 case mf251:
2725 case mf252:
2726 case mf253:
2727 case mf254:
2728 case mfEXTENDED:
2729 5706470 break;
2730
2731 case mfPUSHUD:
2732 case mfPUSHLR:
2733 case mfPUSH4:
2734 case mfPUSHU:
2735 case mfPUSHD:
2736 case mfPUSHL:
2737 case mfPUSHR:
2738 case mfPUSHUDNS:
2739 case mfPUSHLRNS:
2740 case mfPUSH4NS:
2741 case mfPUSHUNS:
2742 case mfPUSHDNS:
2743 case mfPUSHLNS:
2744 case mfPUSHRNS:
2745 case mfPUSHUDINS:
2746 case mfPUSHLRINS:
2747 case mfPUSH4INS:
2748 case mfPUSHUINS:
2749 case mfPUSHDINS:
2750 case mfPUSHLINS:
2751 case mfPUSHRINS:
2752
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2753
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2754 {
2755 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2756 }
2757
2758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2759
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2760 {
2761
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2762 {
2763
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2764 {
2765 case cPUSH_HEAVY:
2766 case cPUSH_HW:
2767 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2768 72 tempitemx=x, tempitemy=y;
2769
2770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2771 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2772
2773 72 break;
2774
2775 case cPUSH_HEAVY2:
2776 case cPUSH_HW2:
2777 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2778 63 tempitemx=x, tempitemy=y;
2779
2780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2781 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2782
2783 63 break;
2784 }
2785 1032 }
2786 2438 }
2787
2788 3148 break;
2789
2790 case mfWHISTLE:
2791
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2792 {
2793 tempitem=getItemID(itemsbuf,itype_whistle,1);
2794
2795 if(tempitem<0) break;
2796
2797 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2798 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2799 {
2800 tempitemx=x;
2801 tempitemy=y;
2802 }
2803
2804 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2805 }
2806
2807 2418 break;
2808
2809 //Why is this here?
2810 case mfFAIRY:
2811 case mfMAGICFAIRY:
2812 case mfALLFAIRY:
2813 if(hints)
2814 {
2815 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2816
2817 if(tempitem < 0) break;
2818
2819 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2820 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2821 {
2822 tempitemx=x;
2823 tempitemy=y;
2824 }
2825
2826 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2827 }
2828
2829 break;
2830
2831 case mfBCANDLE:
2832
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2833 {
2834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2835 252 }
2836 else
2837 {
2838 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2839
2840
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2841
2842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2843
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2844 {
2845 189 tempitemx=x;
2846 189 tempitemy=y;
2847 189 }
2848
2849 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2850 }
2851
2852 504 break;
2853
2854 case mfRCANDLE:
2855 if(!hints)
2856 {
2857 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2858 }
2859 else
2860 {
2861 tempitem=getItemID(itemsbuf,itype_candle,2);
2862
2863 if(tempitem<0) break;
2864
2865 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2866 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2867 {
2868 tempitemx=x;
2869 tempitemy=y;
2870 }
2871
2872 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2873 }
2874
2875 break;
2876
2877 case mfWANDFIRE:
2878 if(!hints)
2879 {
2880 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2881 }
2882 else
2883 {
2884 tempitem=getItemID(itemsbuf,itype_wand,1);
2885
2886 if(tempitem<0) break;
2887
2888 tempweapon=wFire;
2889
2890 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2891 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2892 {
2893 tempitemx=x;
2894 tempitemy=y;
2895 }
2896 else
2897 {
2898 tempweaponx=x;
2899 tempweapony=y;
2900 }
2901
2902 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2903 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2904 }
2905
2906 break;
2907
2908 case mfDINSFIRE:
2909 if(!hints)
2910 {
2911 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2912 }
2913 else
2914 {
2915 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2916
2917 if(tempitem<0) break;
2918
2919 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2920 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2921 {
2922 tempitemx=x;
2923 tempitemy=y;
2924 }
2925
2926 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2927 }
2928
2929 break;
2930
2931 case mfARROW:
2932
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2933 {
2934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2935 732 }
2936 else
2937 {
2938 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2939
2940
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2941
2942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2943
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2944 {
2945 61 tempitemx=x;
2946 61 tempitemy=y;
2947 61 }
2948
2949 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2950 }
2951
2952 814 break;
2953
2954 case mfSARROW:
2955 if(!hints)
2956 {
2957 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2958 }
2959 else
2960 {
2961 tempitem=getItemID(itemsbuf,itype_arrow,2);
2962
2963 if(tempitem<0) break;
2964
2965 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2966 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2967 {
2968 tempitemx=x;
2969 tempitemy=y;
2970 }
2971
2972 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2973 }
2974
2975 break;
2976
2977 case mfGARROW:
2978 if(!hints)
2979 {
2980 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2981 }
2982 else
2983 {
2984 tempitem=getItemID(itemsbuf,itype_arrow,3);
2985
2986 if(tempitem<0) break;
2987
2988 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2989 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2990 {
2991 tempitemx=x;
2992 tempitemy=y;
2993 }
2994
2995 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2996 }
2997
2998 break;
2999
3000 case mfBOMB:
3001
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3002 {
3003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3004 16 }
3005 else
3006 {
3007 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3008 17 tempweapon = wLitBomb;
3009
3010 //if (tempitem<0) break;
3011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3012
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3013 {
3014 12 tempweaponx=x;
3015 12 tempweapony=y;
3016 12 }
3017
3018 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3019 }
3020
3021 33 break;
3022
3023 case mfSBOMB:
3024
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3025 {
3026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3027 48 }
3028 else
3029 {
3030 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3031 //if (tempitem<0) break;
3032 48 tempweapon = wLitSBomb;
3033
3034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3035
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3036 {
3037 36 tempweaponx=x;
3038 36 tempweapony=y;
3039 36 }
3040
3041 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3042 }
3043
3044 96 break;
3045
3046 case mfARMOS_SECRET:
3047
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3048 {
3049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3050 12 }
3051 24 break;
3052
3053 case mfBRANG:
3054
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3055 {
3056 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3057 }
3058 else
3059 {
3060 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3061
3062
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3063
3064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3065
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3066 {
3067 4 tempitemx=x;
3068 4 tempitemy=y;
3069 4 }
3070
3071 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3072 }
3073
3074 5 break;
3075
3076 case mfMBRANG:
3077 if(!hints)
3078 {
3079 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3080 }
3081 else
3082 {
3083 tempitem=getItemID(itemsbuf,itype_brang,2);
3084
3085 if(tempitem<0) break;
3086
3087 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3088 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3089 {
3090 tempitemx=x;
3091 tempitemy=y;
3092 }
3093
3094 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3095 }
3096
3097 break;
3098
3099 case mfFBRANG:
3100 if(!hints)
3101 {
3102 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3103 }
3104 else
3105 {
3106 tempitem=getItemID(itemsbuf,itype_brang,3);
3107
3108 if(tempitem<0) break;
3109
3110 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3111 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3112 {
3113 tempitemx=x;
3114 tempitemy=y;
3115 }
3116
3117 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3118 }
3119
3120 break;
3121
3122 case mfWANDMAGIC:
3123 if(!hints)
3124 {
3125 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3126 }
3127 else
3128 {
3129 tempitem=getItemID(itemsbuf,itype_wand,1);
3130
3131 if(tempitem<0) break;
3132
3133 tempweapon=itemsbuf[tempitem].wpn3;
3134
3135 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3136 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3137 {
3138 tempitemx=x;
3139 tempitemy=y;
3140 }
3141 else
3142 {
3143 tempweaponx=x;
3144 tempweapony=y;
3145 --lens_hint_weapon[wMagic][4];
3146
3147 if(lens_hint_weapon[wMagic][4]<-8)
3148 {
3149 lens_hint_weapon[wMagic][4]=8;
3150 }
3151 }
3152
3153 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3154 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3155 }
3156
3157 break;
3158
3159 case mfREFMAGIC:
3160
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3161 {
3162 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3163 }
3164 else
3165 {
3166 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3167
3168
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3169
3170 16 tempweapon=ewMagic;
3171
3172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3173
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3174 {
3175 13 tempitemx=x;
3176 13 tempitemy=y;
3177 13 }
3178 else
3179 {
3180 3 tempweaponx=x;
3181 3 tempweapony=y;
3182
3183
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3184 {
3185 1 --lens_hint_weapon[ewMagic][4];
3186 1 }
3187 else
3188 {
3189 2 ++lens_hint_weapon[ewMagic][4];
3190 }
3191
3192
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3193 {
3194 lens_hint_weapon[ewMagic][2]=up;
3195 }
3196
3197
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3198 {
3199 2 lens_hint_weapon[ewMagic][2]=down;
3200 2 }
3201 }
3202
3203 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3204 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3205 }
3206
3207 16 break;
3208
3209 case mfREFFIREBALL:
3210
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3211 {
3212 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3213 }
3214 else
3215 {
3216 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3217
3218
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3219
3220 16 tempweapon=ewFireball;
3221
3222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3223
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3224 {
3225 12 tempitemx=x;
3226 12 tempitemy=y;
3227 12 tempweaponx=x;
3228 12 tempweapony=y;
3229 12 ++lens_hint_weapon[ewFireball][3];
3230
3231
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3232 {
3233 1 lens_hint_weapon[ewFireball][3]=-8;
3234 1 lens_hint_weapon[ewFireball][4]=8;
3235 1 }
3236
3237
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3238 {
3239 8 ++lens_hint_weapon[ewFireball][4];
3240 8 }
3241 else
3242 {
3243 4 --lens_hint_weapon[ewFireball][4];
3244 }
3245 12 }
3246
3247 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3248 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3249 }
3250
3251 16 break;
3252
3253 case mfSWORD:
3254
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3255 {
3256 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3257 }
3258 else
3259 {
3260 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3261
3262
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3263
3264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3265
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3266 {
3267 5 tempitemx=x;
3268 5 tempitemy=y;
3269 5 }
3270
3271 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3272 }
3273
3274 7 break;
3275
3276 case mfWSWORD:
3277 if(!hints)
3278 {
3279 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3280 }
3281 else
3282 {
3283 tempitem=getItemID(itemsbuf,itype_sword,2);
3284
3285 if(tempitem<0) break;
3286
3287 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3288 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3289 {
3290 tempitemx=x;
3291 tempitemy=y;
3292 }
3293
3294 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3295 }
3296
3297 break;
3298
3299 case mfMSWORD:
3300 if(!hints)
3301 {
3302 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3303 }
3304 else
3305 {
3306 tempitem=getItemID(itemsbuf,itype_sword,3);
3307
3308 if(tempitem<0) break;
3309
3310 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3311 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3312 {
3313 tempitemx=x;
3314 tempitemy=y;
3315 }
3316
3317 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3318 }
3319
3320 break;
3321
3322 case mfXSWORD:
3323 if(!hints)
3324 {
3325 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3326 }
3327 else
3328 {
3329 tempitem=getItemID(itemsbuf,itype_sword,4);
3330
3331 if(tempitem<0) break;
3332
3333 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3334 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3335 {
3336 tempitemx=x;
3337 tempitemy=y;
3338 }
3339
3340 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3341 }
3342
3343 break;
3344
3345 case mfSWORDBEAM:
3346
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3347 {
3348 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3349 }
3350 else
3351 {
3352 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3353
3354
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3355
3356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3357
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3358 {
3359 11 tempitemx=x;
3360 11 tempitemy=y;
3361 11 }
3362
3363 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3364 }
3365
3366 16 break;
3367
3368 case mfWSWORDBEAM:
3369 if(!hints)
3370 {
3371 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3372 }
3373 else
3374 {
3375 tempitem=getItemID(itemsbuf,itype_sword,2);
3376
3377 if(tempitem<0) break;
3378
3379 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3380 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3381 {
3382 tempitemx=x;
3383 tempitemy=y;
3384 }
3385
3386 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3387 }
3388
3389 break;
3390
3391 case mfMSWORDBEAM:
3392 if(!hints)
3393 {
3394 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3395 }
3396 else
3397 {
3398 tempitem=getItemID(itemsbuf,itype_sword,3);
3399
3400 if(tempitem<0) break;
3401
3402 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3403 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3404 {
3405 tempitemx=x;
3406 tempitemy=y;
3407 }
3408
3409 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3410 }
3411
3412 break;
3413
3414 case mfXSWORDBEAM:
3415 if(!hints)
3416 {
3417 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3418 }
3419 else
3420 {
3421 tempitem=getItemID(itemsbuf,itype_sword,4);
3422
3423 if(tempitem<0) break;
3424
3425 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3426 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3427 {
3428 tempitemx=x;
3429 tempitemy=y;
3430 }
3431
3432 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3433 }
3434
3435 break;
3436
3437 case mfHOOKSHOT:
3438
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3439 {
3440 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3441 }
3442 else
3443 {
3444 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3445
3446
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3447
3448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3449
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3450 {
3451 12 tempitemx=x;
3452 12 tempitemy=y;
3453 12 }
3454
3455 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3456 }
3457
3458 17 break;
3459
3460 case mfWAND:
3461
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3462 {
3463 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3464 }
3465 else
3466 {
3467 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3468
3469
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3470
3471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3472
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3473 {
3474 28 tempitemx=x;
3475 28 tempitemy=y;
3476 28 }
3477
3478 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3479 }
3480
3481 35 break;
3482
3483 case mfHAMMER:
3484
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3485 {
3486 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3487 }
3488 else
3489 {
3490 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3491
3492
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3493
3494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3495
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3496 {
3497 13 tempitemx=x;
3498 13 tempitemy=y;
3499 13 }
3500
3501 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3502 }
3503
3504 17 break;
3505
3506 case mfARMOS_ITEM:
3507 case mfDIVE_ITEM:
3508
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3509 {
3510 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3511 2064 }
3512 2064 break;
3513
3514 case 16:
3515 case 17:
3516 case 18:
3517 case 19:
3518 case 20:
3519 case 21:
3520 case 22:
3521 case 23:
3522 case 24:
3523 case 25:
3524 case 26:
3525 case 27:
3526 case 28:
3527 case 29:
3528 case 30:
3529 case 31:
3530
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3532 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3533
3534 3618 break;
3535 case mfSECRETSNEXT:
3536 if(!hints)
3537 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3538 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3539
3540 break;
3541
3542 case mfSTRIKE:
3543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3544 {
3545 906 goto special;
3546 }
3547 else
3548 {
3549 break;
3550 }
3551
3552 28640 default: goto special;
3553
3554 special:
3555
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3556 {
3557
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3558 {
3559 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3560 4913 }
3561 6549 }
3562
3563 29546 break;
3564 }
3565 5748864 }
3566 2874432 }
3567
3568
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3569 {
3570
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3571 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3572
3573
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3574 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3575
3576
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3577 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3578
3579
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3580 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3581
3582
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3583 {
3584 43 showbombeddoor(dest, 0);
3585 43 }
3586
3587
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3588 {
3589 39 showbombeddoor(dest, 1);
3590 39 }
3591
3592
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3593 {
3594 showbombeddoor(dest, 2);
3595 }
3596
3597
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3598 {
3599 37 showbombeddoor(dest, 3);
3600 37 }
3601 8166 }
3602
3603
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3604 {
3605
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3606 {
3607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3608 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3609 1123 }
3610 else
3611 {
3612
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3613 {
3614 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3615 48 int32_t tempitemx=-16;
3616 48 int32_t tempitemy=-16;
3617
3618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3619
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3620 {
3621 24 tempitemx=tmpscr->stairx;
3622 24 tempitemy=tmpscr->stairy+playing_field_offset;
3623 24 }
3624
3625 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3626 48 }
3627 }
3628 2034 }
3629 }
3630 16332 }
3631
3632 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3633
3634 7997 void draw_lens_over()
3635 {
3636 // Oh, what the heck.
3637 static BITMAP *lens_scr = NULL;
3638 static int32_t last_width = -1;
3639 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3640
3641 // Only redraw the circle if the size has changed
3642
2/2
✓ Branch 0 taken 7992 times.
✓ Branch 1 taken 5 times.
7997 if(width != last_width)
3643 {
3644
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(lens_scr == NULL)
3645 {
3646 5 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3647 5 }
3648
3649 5 clear_to_color(lens_scr, BLACK);
3650 5 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3651 5 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3652 5 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3653 5 last_width=width;
3654 5 }
3655
3656 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3657 7997 }
3658
3659 //----------------------------------------------------------------
3660
3661 30701 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3662 {
3663 //recreating a big bitmap every frame is highly sluggish.
3664
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 30699 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
30701 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3665 30701 clear_to_color(wavebuf, BLACK);
3666 30701 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3667
3668 int32_t ofs;
3669 // int32_t amplitude=8;
3670 // int32_t wavelength=4;
3671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30701 times.
30701 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3672
3/6
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3673 30701 int32_t amp2=168;
3674
2/4
✓ Branch 0 taken 30701 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30701 times.
30701 if(flash_reduction_enabled() && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3675 30701 int32_t i=frame%amp2;
3676
3677
2/2
✓ Branch 0 taken 5157768 times.
✓ Branch 1 taken 30701 times.
5188469 for(int32_t j=0; j<168; j++)
3678 {
3679
3/4
✓ Branch 0 taken 2578884 times.
✓ Branch 1 taken 2578884 times.
✓ Branch 2 taken 2578884 times.
✗ Branch 3 not taken.
5157768 if(j&1 && interpol)
3680 {
3681 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3682 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3683 }
3684 else
3685 {
3686 5157768 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3687 }
3688
3689
1/2
✓ Branch 0 taken 5157768 times.
✗ Branch 1 not taken.
5157768 if(ofs)
3690 {
3691
2/2
✓ Branch 0 taken 1320388608 times.
✓ Branch 1 taken 5157768 times.
1325546376 for(int32_t k=0; k<256; k++)
3692 {
3693 1320388608 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3694 1320388608 }
3695 5157768 }
3696 5157768 }
3697 30701 }
3698
3699 2832 void draw_fuzzy(int32_t fuzz)
3700 // draws from right half of scrollbuf to framebuf
3701 {
3702 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3703 byte *start, *si, *di;
3704
3705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2832 times.
2832 if(fuzz<1)
3706 fuzz = 1;
3707
3708 2832 xstep = 128%fuzz;
3709
3710
2/2
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 2242 times.
2832 if(xstep > 0)
3711 2242 xstep = fuzz-xstep;
3712
3713 2832 ystep = 112%fuzz;
3714
3715
2/2
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 2006 times.
2832 if(ystep > 0)
3716 2006 ystep = fuzz-ystep;
3717
3718 2832 firsty = 1;
3719
3720
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 102188 times.
105020 for(y=0; y<224;)
3721 {
3722 102188 start = &(scrollbuf->line[y][256]);
3723
3724
4/4
✓ Branch 0 taken 100772 times.
✓ Branch 1 taken 635784 times.
✓ Branch 2 taken 634368 times.
✓ Branch 3 taken 102188 times.
736556 for(dy=0; dy<ystep && dy+y<224; dy++)
3725 {
3726 634368 si = start;
3727 634368 di = &(framebuf->line[y+dy][0]);
3728 634368 i = xstep;
3729 634368 firstx = 1;
3730
3731
2/2
✓ Branch 0 taken 162398208 times.
✓ Branch 1 taken 634368 times.
163032576 for(dx=0; dx<256; dx++)
3732 {
3733 162398208 *(di++) = *si;
3734
3735
2/2
✓ Branch 0 taken 136838464 times.
✓ Branch 1 taken 25559744 times.
162398208 if(++i >= fuzz)
3736 {
3737
2/2
✓ Branch 0 taken 24925376 times.
✓ Branch 1 taken 634368 times.
25559744 if(!firstx)
3738 24925376 si += fuzz;
3739 else
3740 {
3741 634368 si += fuzz-xstep;
3742 634368 firstx = 0;
3743 }
3744
3745 25559744 i = 0;
3746 25559744 }
3747 162398208 }
3748 634368 }
3749
3750
2/2
✓ Branch 0 taken 99356 times.
✓ Branch 1 taken 2832 times.
102188 if(!firsty)
3751 99356 y += fuzz;
3752 else
3753 {
3754 2832 y += ystep;
3755 2832 ystep = fuzz;
3756 2832 firsty = 0;
3757 }
3758 }
3759 2832 }
3760
3761 6510665 void updatescr(bool allowwavy)
3762 {
3763
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6510636 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
6510665 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3764
4/6
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 6510636 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
6510665 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3765
3766
2/2
✓ Branch 0 taken 6484961 times.
✓ Branch 1 taken 25704 times.
6510665 if(toogam)
3767 {
3768 25704 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3769 25704 }
3770
3771
1/2
✓ Branch 0 taken 6510665 times.
✗ Branch 1 not taken.
6510665 if(Showpal)
3772 dump_pal(framebuf);
3773
3774
2/2
✓ Branch 0 taken 6428643 times.
✓ Branch 1 taken 82022 times.
6510665 if(!Playing)
3775 82022 black_opening_count=0;
3776
3777
2/2
✓ Branch 0 taken 6472715 times.
✓ Branch 1 taken 37950 times.
6510665 if(black_opening_count<0) //shape is opening up
3778 {
3779 37950 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3780
3781
2/4
✓ Branch 0 taken 37950 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37950 times.
37950 if(Advance||(!Paused))
3782 {
3783 37950 ++black_opening_count;
3784 37950 }
3785 37950 }
3786
2/2
✓ Branch 0 taken 6458459 times.
✓ Branch 1 taken 14256 times.
6472715 else if(black_opening_count>0) //shape is closing
3787 {
3788 14256 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3789
3790
2/4
✓ Branch 0 taken 14256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14256 times.
14256 if(Advance||(!Paused))
3791 {
3792 14256 --black_opening_count;
3793 14256 }
3794 14256 }
3795
3796
3/4
✓ Branch 0 taken 6459250 times.
✓ Branch 1 taken 51415 times.
✓ Branch 2 taken 6459250 times.
✗ Branch 3 not taken.
6510665 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3797 {
3798 black_opening_shape = bosCIRCLE;
3799 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3800 refreshTints();
3801 refreshpal=true;
3802 }
3803
3804
2/2
✓ Branch 0 taken 6298112 times.
✓ Branch 1 taken 212553 times.
6510665 if(refreshpal)
3805 {
3806 212553 refreshpal=false;
3807 212553 RAMpal[253] = _RGB(0,0,0);
3808 212553 RAMpal[254] = _RGB(63,63,63);
3809 212553 hw_palette = &RAMpal;
3810 212553 update_hw_pal = true;
3811
3812 212553 create_rgb_table(&rgb_table, RAMpal, NULL);
3813 212553 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3814 212553 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3815
3816
2/2
✓ Branch 0 taken 54413568 times.
✓ Branch 1 taken 212553 times.
54626121 for(int32_t q=0; q<PAL_SIZE; q++)
3817 {
3818 54413568 trans_table2.data[0][q] = q;
3819 54413568 trans_table2.data[q][q] = q;
3820 54413568 }
3821 212553 }
3822
3823 6510665 bool clearwavy = (wavy <= 0);
3824
3825
2/2
✓ Branch 0 taken 7245 times.
✓ Branch 1 taken 6503420 times.
6510665 if(wavy <= 0)
3826 {
3827 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3828 6503420 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3829 6503420 }
3830
3831 6510665 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3832
3833
6/6
✓ Branch 0 taken 30951 times.
✓ Branch 1 taken 6479714 times.
✓ Branch 2 taken 30829 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 30701 times.
6510665 if(wavy && Playing && allowwavy)
3834 {
3835 30701 draw_wavy(framebuf, wavybuf, wavy,false);
3836 30701 }
3837
3838
2/2
✓ Branch 0 taken 6503420 times.
✓ Branch 1 taken 7245 times.
6510665 if(clearwavy)
3839 6503420 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3840
2/4
✓ Branch 0 taken 7245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7245 times.
7245 else if(Playing && !Paused)
3841 7245 wavy--; // Wavy was set by a script. Decrement it.
3842
3843
5/6
✓ Branch 0 taken 6428643 times.
✓ Branch 1 taken 82022 times.
✓ Branch 2 taken 125857 times.
✓ Branch 3 taken 6302786 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 125857 times.
6510665 if(Playing && msgpos && !screenscrolling)
3844 {
3845
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_bg_display_buf->clip))
3846 125857 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3847
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_portrait_display_buf->clip))
3848 125857 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3849
1/2
✓ Branch 0 taken 125857 times.
✗ Branch 1 not taken.
125857 if(!(msg_txt_display_buf->clip))
3850 125857 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3851 125857 }
3852
3853 /*
3854 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3855 {
3856 BITMAP* subBmp = 0;
3857 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3858 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3859 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3860 destroy_bitmap(subBmp);
3861 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3862 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3863 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3864 }
3865 */
3866
3867
2/2
✓ Branch 0 taken 6485486 times.
✓ Branch 1 taken 25179 times.
6510665 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3868
3869
2/2
✓ Branch 0 taken 6485486 times.
✓ Branch 1 taken 25179 times.
6510665 if(nosubscr)
3870 {
3871 25179 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3872 25179 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3873 25179 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3874 25179 }
3875
3876 //TODO: Optimize blit 'overcalls' -Gleeok
3877
2/2
✓ Branch 0 taken 25179 times.
✓ Branch 1 taken 6485486 times.
6510665 BITMAP *source = nosubscr ? panorama : wavybuf;
3878 6510665 blit(source,framebuf,0,0,0,0,256,224);
3879
3880 6510665 update_hw_screen();
3881 6510665 }
3882
3883 //----------------------------------------------------------------
3884
3885 PALETTE sys_pal;
3886
3887 int32_t onGUISnapshot()
3888 {
3889 char buf[200];
3890 int32_t num=0;
3891 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3892 do
3893 {
3894 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3895 }
3896 while(num<99999 && exists(buf));
3897
3898 BITMAP *b = create_bitmap_ex(8,resx,resy);
3899
3900 if(b)
3901 {
3902 if(MenuOpen)
3903 {
3904 //Cannot load game's palette while GUI elements are in focus. -Z
3905 //If there is a way to do this, then I have missed it.
3906 /*
3907 game_pal();
3908 RAMpal[253] = _RGB(0,0,0);
3909 RAMpal[254] = _RGB(63,63,63);
3910 set_palette_range(RAMpal,0,255,false);
3911 memcpy(RAMpal, snappal, sizeof(snappal));
3912 create_rgb_table(&rgb_table, RAMpal, NULL);
3913 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3914 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3915
3916 for(int32_t q=0; q<PAL_SIZE; q++)
3917 {
3918 trans_table2.data[0][q] = q;
3919 trans_table2.data[q][q] = q;
3920 }
3921 */
3922 //ringcolor(false);
3923 //get_palette(RAMpal);
3924 blit(screen,b,0,0,0,0,resx,resy);
3925 //al_trace("Menu Open\n");
3926 //game_pal();
3927 //PALETTE temppal;
3928 //get_palette(temppal);
3929 //system_pal();
3930 save_bitmap(buf,b,sys_pal);
3931 //save_bitmap(buf,b,RAMpal);
3932 //save_bitmap(buf,b,snappal);
3933 }
3934 else
3935 {
3936 blit(screen,b,0,0,0,0,resx,resy);
3937 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3938 }
3939 destroy_bitmap(b);
3940 }
3941
3942 return D_O_K;
3943 }
3944
3945 int32_t onNonGUISnapshot()
3946 {
3947 PALETTE temppal;
3948 get_palette(temppal);
3949 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3950
3951 char buf[200];
3952 int32_t num=0;
3953
3954 do
3955 {
3956 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3957 }
3958 while(num<99999 && exists(buf));
3959
3960 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3961
3962 return D_O_K;
3963 }
3964
3965 int32_t onSnapshot()
3966 {
3967 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3968 {
3969 onGUISnapshot();
3970 }
3971 else
3972 {
3973 onNonGUISnapshot();
3974 }
3975
3976 return D_O_K;
3977 }
3978
3979 int32_t onSaveMapPic()
3980 {
3981 int32_t mapres2 = 0;
3982 char buf[200];
3983 int32_t num=0;
3984 mapscr tmpscr_b[2];
3985 mapscr tmpscr_c[6];
3986 BITMAP* _screen_draw_buffer = NULL;
3987 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3988 set_clip_state(_screen_draw_buffer,1);
3989
3990 for(int32_t i=0; i<6; ++i)
3991 {
3992 tmpscr_c[i] = tmpscr2[i];
3993 tmpscr2[i].zero_memory();
3994
3995 if(i>=2)
3996 {
3997 continue;
3998 }
3999
4000 tmpscr_b[i] = tmpscr[i];
4001 tmpscr[i].zero_memory();
4002 }
4003
4004 do
4005 {
4006 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4007 }
4008 while(num<99999 && exists(buf));
4009
4010 BITMAP* mappic = NULL;
4011
4012
4013 bool done=false, redraw=true;
4014
4015 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4016
4017 if(!mappic)
4018 {
4019 system_pal();
4020 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4021 game_pal();
4022 return D_O_K;;
4023 }
4024
4025 // draw the map
4026 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4027
4028 for(int32_t y=0; y<8; y++)
4029 {
4030 for(int32_t x=0; x<16; x++)
4031 {
4032 if(!displayOnMap(x, y))
4033 {
4034 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4035 }
4036 else
4037 {
4038 int32_t s = (y<<4) + x;
4039 loadscr2(1,s,-1);
4040
4041 for(int32_t i=0; i<6; i++)
4042 {
4043 if(tmpscr[1].layermap[i]<=0)
4044 continue;
4045
4046 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4047 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4048 {
4049 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4050
4051 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4052 }
4053 }
4054
4055 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4056
4057 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4058
4059 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4060 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4061
4062 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4063
4064 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4065 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4066 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4067 {
4068 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4069 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4070 }
4071 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4072
4073 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4074
4075 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4076 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4077 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4078 {
4079 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4080 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4081 }
4082 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4083 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4084
4085 }
4086
4087 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4088 }
4089 }
4090
4091 for(int32_t i=0; i<6; ++i)
4092 {
4093 tmpscr2[i]=tmpscr_c[i];
4094
4095 if(i>=2)
4096 {
4097 continue;
4098 }
4099
4100 tmpscr[i]=tmpscr_b[i];
4101 }
4102
4103 save_bitmap(buf,mappic,RAMpal);
4104 destroy_bitmap(mappic);
4105 destroy_bitmap(_screen_draw_buffer);
4106 return D_O_K;
4107 }
4108
4109 /*
4110 int32_t onSaveMapPic()
4111 {
4112 BITMAP* mappic = NULL;
4113 BITMAP* _screen_draw_buffer = NULL;
4114 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4115 int32_t mapres2 = 0;
4116 char buf[20];
4117 int32_t num=0;
4118 set_clip_state(_screen_draw_buffer,1);
4119 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4120
4121 do
4122 {
4123 sprintf(buf, "zelda%03d.png", ++num);
4124 }
4125 while(num<999 && exists(buf));
4126
4127 // if(!mappic) {
4128 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4129
4130 if(!mappic)
4131 {
4132 system_pal();
4133 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4134 game_pal();
4135 return D_O_K;
4136 }
4137
4138 // }
4139
4140 int32_t layermap, layerscreen;
4141 int32_t x2=0;
4142
4143 // draw the map
4144 for(int32_t y=0; y<8; y++)
4145 {
4146 for(int32_t x=0; x<16; x++)
4147 {
4148 int32_t s = (y<<4) + x;
4149
4150 if(!displayOnMap(x, y))
4151 {
4152 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4153 }
4154 else
4155 {
4156 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4157 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4158
4159 for(int32_t k=0; k<4; k++)
4160 {
4161 if(k==2)
4162 {
4163 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4164 }
4165
4166 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4167
4168 if(layermap>-1)
4169 {
4170 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4171
4172 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4173 {
4174 for(int32_t i=0; i<176; i++)
4175 {
4176 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4177 }
4178 }
4179 else
4180 {
4181 for(int32_t i=0; i<176; i++)
4182 {
4183 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4184 }
4185 }
4186 }
4187 }
4188
4189 for(int32_t i=0; i<176; i++)
4190 {
4191 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4192 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4193 {
4194 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4195 }
4196 }
4197
4198 for(int32_t k=4; k<6; k++)
4199 {
4200 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4201
4202 if(layermap>-1)
4203 {
4204 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4205
4206 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4207 {
4208 for(int32_t i=0; i<176; i++)
4209 {
4210 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4211 }
4212 }
4213 else
4214 {
4215 for(int32_t i=0; i<176; i++)
4216 {
4217 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4218 }
4219 }
4220 }
4221 }
4222 }
4223
4224 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4225 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4226 }
4227
4228 }
4229
4230 save_bitmap(buf,mappic,RAMpal);
4231 destroy_bitmap(mappic);
4232 destroy_bitmap(_screen_draw_buffer);
4233 return D_O_K;
4234 }
4235 */
4236
4237 14 void f_Quit(int32_t type)
4238 {
4239
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4240 return;
4241
4242 14 bool from_menu = is_sys_pal;
4243
4244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4245 {
4246 14 music_pause();
4247 14 pause_all_sfx();
4248 14 }
4249 14 enter_sys_pal();
4250 14 clear_keybuf();
4251
4252
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if (replay_is_active() && replay_get_version() <= 9)
4253 14 replay_poll();
4254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4255 14 replay_peek_quit();
4256
4257
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4258 switch(type)
4259 {
4260 case qQUIT:
4261 onQuit();
4262 break;
4263
4264 case qRESET:
4265 onReset();
4266 break;
4267
4268 case qEXIT:
4269 onExit();
4270 break;
4271 }
4272
4273
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4274 {
4275 14 kill_sfx();
4276 14 music_stop();
4277 14 exit_sys_pal();
4278 14 update_hw_screen();
4279 14 }
4280 else
4281 {
4282 exit_sys_pal();
4283 if(!from_menu)
4284 {
4285 music_resume();
4286 resume_all_sfx();
4287 }
4288 }
4289
4290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4291 14 show_mouse(NULL);
4292 14 eat_buttons();
4293
4294 14 zc_readrawkey(KEY_ESC);
4295
4296 14 zc_readrawkey(KEY_ENTER);
4297 14 }
4298
4299 //----------------------------------------------------------------
4300
4301 int32_t onNoWalls()
4302 {
4303 cheats_enqueue(Cheat::Walls);
4304 return D_O_K;
4305 }
4306
4307 int32_t onIgnoreSideview()
4308 {
4309 cheats_enqueue(Cheat::IgnoreSideView);
4310 return D_O_K;
4311 }
4312
4313 6510614 int32_t input_idle(bool checkmouse)
4314 {
4315 static int32_t mx, my, mz, mb;
4316
4317
4/6
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621032 times.
✓ Branch 3 taken 4889582 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1621032 times.
8131646 if(keypressed() || zc_key_pressed() ||
4318
4/8
✓ Branch 0 taken 1621032 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621032 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1621032 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1621032 times.
✗ Branch 7 not taken.
1621032 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4319 {
4320 4889582 idle_count = 0;
4321
4322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4889582 times.
4889582 if(active_count < MAX_ACTIVE)
4323 {
4324 4889582 ++active_count;
4325 4889582 }
4326 4889582 }
4327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1621032 times.
1621032 else if(idle_count < MAX_IDLE)
4328 {
4329 1621032 ++idle_count;
4330 1621032 active_count = 0;
4331 1621032 }
4332
4333 6510614 mx = mouse_x;
4334 6510614 my = mouse_y;
4335 6510614 mz = mouse_z;
4336 6510614 mb = mouse_b;
4337
4338 6510614 return idle_count;
4339 }
4340
4341 int32_t onGoFast()
4342 {
4343 cheats_enqueue(Cheat::Fast);
4344 return D_O_K;
4345 }
4346
4347 int32_t onKillCheat()
4348 {
4349 cheats_enqueue(Cheat::Kill);
4350 return D_O_K;
4351 }
4352
4353 int32_t onSecretsCheat()
4354 {
4355 cheats_enqueue(Cheat::TrigSecrets);
4356 return D_O_K;
4357 }
4358 int32_t onSecretsCheatPerm()
4359 {
4360 cheats_enqueue(Cheat::TrigSecretsPerm);
4361 return D_O_K;
4362 }
4363
4364 int32_t onShowLayer0()
4365 {
4366 show_layer_0 = !show_layer_0;
4367 return D_O_K;
4368 }
4369 int32_t onShowLayer1()
4370 {
4371 show_layer_1 = !show_layer_1;
4372 return D_O_K;
4373 }
4374 int32_t onShowLayer2()
4375 {
4376 show_layer_2 = !show_layer_2;
4377 return D_O_K;
4378 }
4379 int32_t onShowLayer3()
4380 {
4381 show_layer_3 = !show_layer_3;
4382 return D_O_K;
4383 }
4384 int32_t onShowLayer4()
4385 {
4386 show_layer_4 = !show_layer_4;
4387 return D_O_K;
4388 }
4389 int32_t onShowLayer5()
4390 {
4391 show_layer_5 = !show_layer_5;
4392 return D_O_K;
4393 }
4394 int32_t onShowLayer6()
4395 {
4396 show_layer_6 = !show_layer_6;
4397 return D_O_K;
4398 }
4399 int32_t onShowLayerO()
4400 {
4401 show_layer_over=!show_layer_over;
4402 return D_O_K;
4403 }
4404 int32_t onShowLayerP()
4405 {
4406 show_layer_push=!show_layer_push;
4407 return D_O_K;
4408 }
4409 int32_t onShowLayerS()
4410 {
4411 show_sprites=!show_sprites;
4412 return D_O_K;
4413 }
4414 int32_t onShowLayerF()
4415 {
4416 show_ffcs=!show_ffcs;
4417 return D_O_K;
4418 }
4419 int32_t onShowLayerW()
4420 {
4421 show_walkflags=!show_walkflags;
4422 if(show_walkflags)
4423 show_effectflags = false;
4424 return D_O_K;
4425 }
4426 int32_t onShowLayerE()
4427 {
4428 show_effectflags=!show_effectflags;
4429 if(show_effectflags)
4430 show_walkflags = false;
4431 return D_O_K;
4432 }
4433 int32_t onShowFFScripts()
4434 {
4435 show_ff_scripts=!show_ff_scripts;
4436 return D_O_K;
4437 }
4438 int32_t onShowHitboxes()
4439 {
4440 show_hitboxes=!show_hitboxes;
4441 return D_O_K;
4442 }
4443 int32_t onShowInfoOpacity()
4444 {
4445 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4446 zc_set_config("zc","debug_info_opacity",info_opacity);
4447 return D_O_K;
4448 }
4449
4450 int32_t onLightSwitch()
4451 {
4452 cheats_enqueue(Cheat::Light);
4453 return D_O_K;
4454 }
4455
4456 int32_t onGoTo();
4457 int32_t onGoToComplete();
4458
4459 6510614 void syskeys()
4460 {
4461 6510614 update_system_keys();
4462
4463 int32_t oldtitle_version;
4464
4465
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(close_button_quit)
4466 {
4467 close_button_quit=false;
4468 f_Quit(qEXIT);
4469 }
4470
4471 6510614 poll_joystick();
4472
4473
2/10
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6510614 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6510614 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4474 {
4475 oldtitle_version=title_version;
4476 System();
4477 }
4478
4479 6510614 mouse_down=gui_mouse_b();
4480
4481
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F1))
4482 {
4483 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4484 {
4485 halt=!halt;
4486 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4487 }
4488 else
4489 {
4490 Throttlefps=!Throttlefps;
4491 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4492 logic_counter=0;
4493 }
4494 }
4495
4496 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4497 /*
4498 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4499 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4500 */
4501
4502
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F2))
4503 {
4504 ShowFPS=!ShowFPS;
4505 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4506 }
4507
4508
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4509
4510
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(zc_read_system_key(KEY_F4) && Playing)
4511 {
4512 Paused=true;
4513 Advance=true;
4514 }
4515
4516
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F6)) onTryQuit();
4517
4518 #ifndef ALLEGRO_MACOSX
4519
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4520
4521
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4522 #else
4523 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4524
4525 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4526 #endif
4527
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6510614 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4528
4529
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if (zc_read_system_key(KEY_F12))
4530 {
4531 onSnapshot();
4532 }
4533
4534
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6510614 if(debug_enabled && zc_read_system_key(KEY_TAB))
4535 set_debug(!get_debug());
4536
4537
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(CheatModifierKeys())
4538 {
4539 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4540 {
4541 if(!bindable_cheat(c))
4542 continue;
4543 if(get_debug() || cheat >= cheat_lvl(c))
4544 {
4545 if(checkcheat(c))
4546 cheats_hit_bind(c);
4547 }
4548 }
4549 }
4550
4551
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(volkeys)
4552 {
4553 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4554
4555 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4556
4557 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4558
4559 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4560 }
4561
4562
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6510614 if(!get_debug() || !SystemKeys || replay_is_replaying())
4563 6510614 goto bottom;
4564
4565 if(zc_readkey(KEY_D))
4566 {
4567 details = !details;
4568 rectfill(screen,0,0,319,7,BLACK);
4569 rectfill(screen,0,8,31,239,BLACK);
4570 rectfill(screen,288,8,319,239,BLACK);
4571 rectfill(screen,32,232,287,239,BLACK);
4572 }
4573
4574 if(zc_readkey(KEY_P)) Paused=!Paused;
4575
4576 //if(zc_readkey(KEY_P)) centerHero();
4577 if(zc_readkey(KEY_A))
4578 {
4579 Paused=true;
4580 Advance=true;
4581 }
4582
4583 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4584 #ifndef ALLEGRO_MACOSX
4585 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4586
4587 if(zc_readkey(KEY_F7))
4588 {
4589 Matrix(ss_speed, ss_density, 0);
4590 game_pal();
4591 }
4592 #else
4593 // The reason these are different on Mac in the first place is that
4594 // the OS doesn't let us use F9 and F10...
4595 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4596
4597 if(zc_readkey(KEY_F9))
4598 {
4599 Matrix(ss_speed, ss_density, 0);
4600 game_pal();
4601 }
4602 #endif
4603 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4604 {
4605 //change containers
4606 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4607 {
4608 //magic containers
4609 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4610 {
4611 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4612 }
4613 else
4614 {
4615 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4616 }
4617 }
4618 else
4619 {
4620 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4621 {
4622 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4623 }
4624 else
4625 {
4626 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4627 }
4628 }
4629 }
4630
4631 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4632 {
4633 //change containers
4634 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4635 {
4636 //magic containers
4637 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4638 {
4639 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4640 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4641 //heart containers
4642 }
4643 else
4644 {
4645 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4646 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4647 }
4648 }
4649 else
4650 {
4651 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4652 {
4653 game->set_magic(zc_max(game->get_magic()-1,0));
4654 }
4655 else
4656 {
4657 game->set_life(zc_max(game->get_life()-1,0));
4658 }
4659 }
4660 }
4661
4662 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4663
4664 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4665
4666 verifyBothWeapons();
4667
4668 bottom:
4669
4670
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(input_idle(true) > after_time())
4671 {
4672 Matrix(ss_speed, ss_density, 0);
4673 game_pal();
4674 }
4675 6510614 }
4676
4677 330136 void checkQuitKeys()
4678 {
4679 #ifndef ALLEGRO_MACOSX
4680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F9]) f_Quit(qRESET);
4681
4682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330136 times.
330136 if(key[KEY_F10]) f_Quit(qEXIT);
4683 #else
4684 if(key[KEY_F7]) f_Quit(qRESET);
4685
4686 if(key[KEY_F8]) f_Quit(qEXIT);
4687 #endif
4688 330136 }
4689
4690 6510614 bool CheatModifierKeys()
4691 {
4692 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4693 // to trigger cheats.
4694
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if (replay_is_replaying())
4695 6510614 return false;
4696
4697 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4698 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4699 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4700 {
4701 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4702 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4703 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4704 {
4705 return true;
4706 }
4707 }
4708 return false;
4709 6510614 }
4710
4711 //99:05:54, for some reason?
4712 #define OLDMAXTIME 21405240
4713 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4714 #define MAXTIME 1944000000
4715
4716 6510665 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4717 {
4718
2/2
✓ Branch 0 taken 6242564 times.
✓ Branch 1 taken 268101 times.
6510665 if(zcmusic!=NULL)
4719 {
4720 268101 zcmusic_poll();
4721 268101 }
4722
4723 6510665 updatescr(allowwavy);
4724
4725
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6510665 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6510665 times.
6510665 while(Paused && !Advance && !Quit)
4726 {
4727 // have to call this, otherwise we'll get an infinite loop
4728 syskeys();
4729 if(allowF6Script)
4730 {
4731 FFCore.runF6Engine();
4732 }
4733 throttleFPS();
4734
4735 #ifdef _WIN32
4736
4737 if(use_dwm_flush)
4738 {
4739 do_DwmFlush();
4740 }
4741
4742 #endif
4743
4744 // to keep music playing
4745 if(zcmusic!=NULL)
4746 {
4747 zcmusic_poll();
4748 }
4749
4750 update_hw_screen();
4751 }
4752
4753
2/2
✓ Branch 0 taken 6510624 times.
✓ Branch 1 taken 41 times.
6510665 if(Quit)
4754 41 return;
4755
4756
3/4
✓ Branch 0 taken 6428635 times.
✓ Branch 1 taken 81989 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6428635 times.
6510624 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4757 6428635 game->change_time(1);
4758
4759 6510624 Advance=false;
4760
4761
2/4
✓ Branch 0 taken 6510624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6510624 times.
6510624 if (!replay_is_active() || replay_get_version() >= 11)
4762 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4763 down_control_states[i] = raw_control_state[i];
4764
4765
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510622 times.
6510624 if (replay_is_active())
4766 {
4767
2/2
✓ Branch 0 taken 1270461 times.
✓ Branch 1 taken 5240161 times.
6510622 if (replay_get_version() >= 3)
4768 5240161 replay_poll();
4769
4770
5/6
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3089962 times.
✓ Branch 3 taken 3420652 times.
✓ Branch 4 taken 100535 times.
✓ Branch 5 taken 2989427 times.
6510622 if (replay_get_version() >= 11 || (replay_get_version() >= 6 && replay_get_version() < 8))
4771 100535 replay_peek_input();
4772 6510614 }
4773
4774 6510624 load_control_called_this_frame = false;
4775
4776 6510624 poll_keyboard();
4777 6510624 update_keys();
4778
4779 6510624 ++frame;
4780
4781
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510614 times.
6510624 if (replay_is_replaying())
4782 6510614 replay_do_cheats();
4783 6510624 syskeys();
4784
4785 // The mouse variables can change from the mouse thread at anytime during a frame,
4786 // so save the result at the start so that replaying is consistent.
4787 6510624 script_mouse_x = gui_mouse_x();
4788 6510624 script_mouse_y = gui_mouse_y();
4789 6510624 script_mouse_z = mouse_z;
4790 6510624 script_mouse_b = mouse_b;
4791
4792 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4793 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4794 // approach here means it doesn't matter which call adds the cheat.
4795 6510624 cheats_execute_queued();
4796
4797
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6510614 times.
6510624 if (replay_is_replaying())
4798 6510614 replay_peek_quit();
4799
2/2
✓ Branch 0 taken 6510610 times.
✓ Branch 1 taken 14 times.
6510624 if (GameFlags & GAMEFLAG_TRYQUIT)
4800 14 replay_step_quit(0);
4801
2/2
✓ Branch 0 taken 1835 times.
✓ Branch 1 taken 6508789 times.
6510624 if(allowF6Script)
4802 {
4803 6508789 FFCore.runF6Engine();
4804 6508789 }
4805
2/2
✓ Branch 0 taken 6510449 times.
✓ Branch 1 taken 175 times.
6510624 if (Quit)
4806 175 replay_step_quit(Quit);
4807 // Someday... maybe install a Turbo button here?
4808 6510624 throttleFPS();
4809
4810 #ifdef _WIN32
4811
4812 if(use_dwm_flush)
4813 {
4814 do_DwmFlush();
4815 }
4816
4817 #endif
4818
4819 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4820
2/2
✓ Branch 0 taken 29901 times.
✓ Branch 1 taken 6480723 times.
6510624 if(sfxcleanup)
4821 6480723 sfx_cleanup();
4822 6510665 }
4823
4824 59 void zapout()
4825 {
4826 59 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4827 59 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4828
4829 59 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4830 59 script_drawing_commands.Clear();
4831
4832 // zap out
4833
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1416 times.
1475 for(int32_t i=1; i<=24; i++)
4834 {
4835 1416 draw_fuzzy(i);
4836 1416 advanceframe(true);
4837
4838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1416 times.
1416 if(Quit)
4839 {
4840 break;
4841 }
4842 1416 }
4843 59 }
4844
4845 59 void zapin()
4846 {
4847 59 FFCore.warpScriptCheck();
4848 59 draw_screen(tmpscr);
4849 59 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4850 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4851 59 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4852
4853 // zap out
4854 59 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4855
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1416 times.
1475 for(int32_t i=24; i>=1; i--)
4856 {
4857 1416 draw_fuzzy(i);
4858 1416 advanceframe(true);
4859
4860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1416 times.
1416 if(Quit)
4861 {
4862 break;
4863 }
4864 1416 }
4865 59 }
4866
4867
4868 23 void wavyout(bool showhero)
4869 {
4870 23 draw_screen(tmpscr, showhero);
4871 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4872
4873 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4874 23 clear_to_color(wavebuf,0);
4875 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4876
4877 static PALETTE wavepal;
4878
4879 int32_t ofs;
4880 23 int32_t amplitude=8;
4881
4882 23 int32_t wavelength=4;
4883 23 double palpos=0, palstep=4, palstop=126;
4884
4885 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4886
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4887 {
4888
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4889 {
4890 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4891 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4892 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4893 247296 }
4894
4895 966 palpos+=palstep;
4896
4897
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4898 {
4899 966 hw_palette = &wavepal;
4900 966 update_hw_pal = true;
4901 966 }
4902 else
4903 {
4904 hw_palette = &RAMpal;
4905 update_hw_pal = true;
4906 }
4907
4908
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4909 {
4910
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4911 {
4912 41545728 ofs=0;
4913
4914
4/4
✓ Branch 0 taken 20278272 times.
✓ Branch 1 taken 21267456 times.
✓ Branch 2 taken 10139136 times.
✓ Branch 3 taken 10139136 times.
41545728 if((j<i)&&(j&1))
4915 {
4916 10139136 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4917 10139136 }
4918
4919 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4920 41545728 }
4921 162288 }
4922
4923 966 advanceframe(true);
4924
4925 // animate_combos();
4926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4927 break;
4928 966 }
4929
4930 23 destroy_bitmap(wavebuf);
4931 23 }
4932
4933 23 void wavyin()
4934 {
4935 23 draw_screen(tmpscr);
4936 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4937
4938 23 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4939 23 clear_to_color(wavebuf,0);
4940 23 blit(framebuf,wavebuf,0,0,16,0,256,224);
4941
4942 static PALETTE wavepal;
4943
4944 //Breaks dark rooms.
4945 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4946 /*
4947 loadfullpal();
4948 loadlvlpal(DMaps[currdmap].color);
4949 ringcolor(false);
4950 */
4951 23 refreshpal=false;
4952 int32_t ofs;
4953 23 int32_t amplitude=8;
4954 23 int32_t wavelength=4;
4955 23 double palpos=168, palstep=4, palstop=126;
4956
4957 23 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4958
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 966 times.
989 for(int32_t i=0; i<168; i+=wavelength)
4959 {
4960
2/2
✓ Branch 0 taken 247296 times.
✓ Branch 1 taken 966 times.
248262 for(int32_t l=0; l<256; l++)
4961 {
4962 247296 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4963 247296 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4964 247296 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4965 247296 }
4966
4967 966 palpos-=palstep;
4968
4969
1/2
✓ Branch 0 taken 966 times.
✗ Branch 1 not taken.
966 if(palpos>=0)
4970 {
4971 966 hw_palette = &wavepal;
4972 966 update_hw_pal = true;
4973 966 }
4974 else
4975 {
4976 hw_palette = &RAMpal;
4977 update_hw_pal = true;
4978 }
4979
4980
2/2
✓ Branch 0 taken 162288 times.
✓ Branch 1 taken 966 times.
163254 for(int32_t j=0; j+playing_field_offset<224; j++)
4981 {
4982
2/2
✓ Branch 0 taken 41545728 times.
✓ Branch 1 taken 162288 times.
41708016 for(int32_t k=0; k<256; k++)
4983 {
4984 41545728 ofs=0;
4985
4986
4/4
✓ Branch 0 taken 21020160 times.
✓ Branch 1 taken 20525568 times.
✓ Branch 2 taken 10633728 times.
✓ Branch 3 taken 10386432 times.
41545728 if((j<(167-i))&&(j&1))
4987 {
4988 10386432 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4989 10386432 }
4990
4991 41545728 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4992 41545728 }
4993 162288 }
4994
4995 966 advanceframe(true);
4996 // animate_combos();
4997
4998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 966 times.
966 if(Quit)
4999 break;
5000 966 }
5001
5002 23 destroy_bitmap(wavebuf);
5003 23 }
5004
5005 1619 void blackscr(int32_t fcnt,bool showsubscr)
5006 {
5007 1619 reset_pal_cycling();
5008 1619 script_drawing_commands.Clear();
5009
5010 1619 FFCore.warpScriptCheck();
5011 1619 bool showtime = game->should_show_time();
5012
2/2
✓ Branch 0 taken 1619 times.
✓ Branch 1 taken 48500 times.
50119 while(fcnt>0)
5013 {
5014 48500 clear_bitmap(framebuf);
5015
5016
2/2
✓ Branch 0 taken 13500 times.
✓ Branch 1 taken 35000 times.
48500 if(showsubscr)
5017 {
5018 35000 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5019
3/4
✓ Branch 0 taken 35000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 34250 times.
35000 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5020 {
5021 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5022 750 }
5023 35000 }
5024
5025 48500 advanceframe(true);
5026
5027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48500 times.
48500 if(Quit)
5028 break;
5029
5030 48500 --fcnt;
5031 }
5032 1619 }
5033
5034 563 void openscreen(int32_t shape)
5035 {
5036 563 reset_pal_cycling();
5037 563 black_opening_count=0;
5038
5039
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 465 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
563 if(COOLSCROLL || shape>-1)
5040 {
5041 465 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5042 465 return;
5043 }
5044 else
5045 {
5046 98 Hero.setDontDraw(true);
5047 98 show_subscreen_dmap_dots=false;
5048 98 show_subscreen_numbers=false;
5049 // show_subscreen_items=false;
5050 98 show_subscreen_life=false;
5051 }
5052
5053 98 int32_t x=128;
5054
5055 98 FFCore.warpScriptCheck();
5056
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 7840 times.
7938 for(int32_t i=0; i<80; i++)
5057 {
5058 7840 draw_screen(tmpscr);
5059 //? draw_screen already draws the subscreen -DD
5060 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5061 7840 x=128-(((i*128/80)/8)*8);
5062
5063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(x>0)
5064 {
5065 7840 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5066 7840 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5067 7840 }
5068
5069 7840 advanceframe(true);
5070
5071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7840 times.
7840 if(Quit)
5072 {
5073 break;
5074 }
5075 7840 }
5076
5077 98 Hero.setDontDraw(false);
5078 98 show_subscreen_items=true;
5079 98 show_subscreen_dmap_dots=true;
5080 563 }
5081
5082 void closescreen(int32_t shape)
5083 {
5084 reset_pal_cycling();
5085 black_opening_count=0;
5086
5087 if(COOLSCROLL || shape>-1)
5088 {
5089 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5090 return;
5091 }
5092 else
5093 {
5094 Hero.setDontDraw(true);
5095 show_subscreen_dmap_dots=false;
5096 show_subscreen_numbers=false;
5097 // show_subscreen_items=false;
5098 show_subscreen_life=false;
5099 }
5100
5101 int32_t x=128;
5102
5103 FFCore.warpScriptCheck();
5104 for(int32_t i=79; i>=0; --i)
5105 {
5106 draw_screen(tmpscr);
5107 //? draw_screen already draws the subscreen -DD
5108 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5109 x=128-(((i*128/80)/8)*8);
5110
5111 if(x>0)
5112 {
5113 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5114 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5115 }
5116
5117 advanceframe(true);
5118
5119 if(Quit)
5120 {
5121 break;
5122 }
5123 }
5124
5125 Hero.setDontDraw(false);
5126 show_subscreen_items=true;
5127 show_subscreen_dmap_dots=true;
5128 }
5129
5130 122 int32_t TriforceCount()
5131 {
5132 122 int32_t c=0;
5133
5134
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 122 times.
1098 for(int32_t i=1; i<=8; i++)
5135
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 650 times.
1626 if(game->lvlitems[i]&liTRIFORCE)
5136 650 ++c;
5137
5138 122 return c;
5139 }
5140
5141 int32_t onCustomGame()
5142 {
5143 int32_t file = getsaveslot();
5144
5145 if(file < 0)
5146 return D_O_K;
5147
5148 bool ret = (custom_game(file)!=0);
5149 return ret ? D_CLOSE : D_O_K;
5150 }
5151
5152 int32_t onContinue()
5153 {
5154 return D_CLOSE;
5155 }
5156
5157 int32_t onEsc() // Unused?? -L
5158 {
5159 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5160 }
5161
5162 int32_t onVsync()
5163 {
5164 Throttlefps = !Throttlefps;
5165 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5166 return D_O_K;
5167 }
5168
5169 int32_t onWinPosSave()
5170 {
5171 SaveWinPos = !SaveWinPos;
5172 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5173 return D_O_K;
5174 }
5175
5176 int32_t onClickToFreeze()
5177 {
5178 ClickToFreeze = !ClickToFreeze;
5179 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5180 return D_O_K;
5181 }
5182
5183 int32_t OnSaveZCConfig()
5184 {
5185 if(jwin_alert3(
5186 "Save Configuration",
5187 "Are you sure that you wish to save your present configuration settings?",
5188 "This will overwrite your prior settings!",
5189 NULL,
5190 "&Yes",
5191 "&No",
5192 NULL,
5193 'y',
5194 'n',
5195 0,
5196 lfont) == 1)
5197 {
5198 save_game_configs();
5199 return D_O_K;
5200 }
5201 else return D_O_K;
5202 }
5203
5204 int32_t OnnClearQuestDir()
5205 {
5206 if(jwin_alert3(
5207 "Clear Current Directory Cache",
5208 "Are you sure that you wish to clear the current cached directory?",
5209 "This will default the current directory to the ROOT for this instance of ZC Player!",
5210 NULL,
5211 "&Yes",
5212 "&No",
5213 NULL,
5214 'y',
5215 'n',
5216 0,
5217 lfont) == 1)
5218 {
5219 zc_set_config("zeldadx","win_qst_dir","");
5220 flush_config_file();
5221 strcpy(qstdir,"");
5222 #ifdef __EMSCRIPTEN__
5223 em_sync_fs();
5224 #endif
5225 return D_O_K;
5226 }
5227 else return D_O_K;
5228 }
5229
5230
5231 int32_t onConsoleZASM()
5232 {
5233 if ( !zasm_debugger )
5234 {
5235 AlertDialog("WARNING: ZASM Debugger",
5236 "Enabling this will open the ZASM Debugger Console"
5237 "\nThis will likely grind ZC to a halt with lag."
5238 "\nTo make any use of this, it is suggested that you read"
5239 "\nthe documentation for 'void Breakpoint(char[] string);'"
5240 " in 'ZScript_Additions.txt'"
5241 "\nThis is not recommended for normal users,"
5242 " and is only intended for ZC developers,"
5243 "\nor quest developers coding directly in ZASM"
5244 "\nAre you sure that you wish to open the ZASM Debugger?",
5245 [&](bool ret,bool)
5246 {
5247 if(ret)
5248 {
5249 FFCore.ZASMPrint(true);
5250 }
5251 }).show();
5252 return D_O_K;
5253 }
5254 else
5255 {
5256 FFCore.ZASMPrint(false);
5257 return D_O_K;
5258 }
5259 }
5260
5261
5262 int32_t onConsoleZScript()
5263 {
5264 if ( !zscript_debugger )
5265 {
5266 AlertDialog("ZScript Debugger",
5267 "Enabling this will open the ZScript Debugger Console"
5268 "\nThis will display any messages logged by scripts,"
5269 " including script errors."
5270 "\nAre you sure that you wish to open the ZScript Debugger?",
5271 [&](bool ret,bool)
5272 {
5273 if(ret)
5274 {
5275 FFCore.ZScriptConsole(true);
5276 }
5277 }).show();
5278 return D_O_K;
5279 }
5280 else
5281 {
5282 FFCore.ZScriptConsole(false);
5283 return D_O_K;
5284 }
5285 }
5286
5287 int32_t onClrConsoleOnLoad()
5288 {
5289 clearConsoleOnLoad = !clearConsoleOnLoad;
5290 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5291 return D_O_K;
5292 }
5293
5294
5295 int32_t onFrameSkip()
5296 {
5297 FrameSkip = !FrameSkip;
5298 return D_O_K;
5299 }
5300
5301 int32_t onSaveDragResize()
5302 {
5303 SaveDragResize = !SaveDragResize;
5304 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5305 return D_O_K;
5306 }
5307
5308 int32_t onDragAspect()
5309 {
5310 DragAspect = !DragAspect;
5311 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5312 return D_O_K;
5313 }
5314
5315 int32_t onTransLayers()
5316 {
5317 TransLayers = !TransLayers;
5318 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5319 return D_O_K;
5320 }
5321
5322 int32_t onNESquit()
5323 {
5324 NESquit = !NESquit;
5325 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5326 return D_O_K;
5327 }
5328
5329 int32_t onVolKeys()
5330 {
5331 volkeys = !volkeys;
5332 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5333 return D_O_K;
5334 }
5335
5336 int32_t onShowFPS()
5337 {
5338 ShowFPS = !ShowFPS;
5339 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5340 return D_O_K;
5341 }
5342
5343 768252452 bool is_Fkey(int32_t k)
5344 {
5345
2/2
✓ Branch 0 taken 78127368 times.
✓ Branch 1 taken 690125084 times.
768252452 switch(k)
5346 {
5347 case KEY_F1:
5348 case KEY_F2:
5349 case KEY_F3:
5350 case KEY_F4:
5351 case KEY_F5:
5352 case KEY_F6:
5353 case KEY_F7:
5354 case KEY_F8:
5355 case KEY_F9:
5356 case KEY_F10:
5357 case KEY_F11:
5358 case KEY_F12:
5359 78127368 return true;
5360 }
5361
5362 690125084 return false;
5363 768252452 }
5364
5365 void kb_getkey(DIALOG *d);
5366
5367 //Used by all keyboard key settings dialogues.
5368 void kb_clearjoystick(DIALOG *d)
5369 {
5370 d->flags|=D_SELECTED;
5371
5372 scare_mouse();
5373 jwin_button_proc(MSG_DRAW,d,0);
5374 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5375 // text_mode(vc(11));
5376 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5377 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5378 unscare_mouse();
5379
5380 update_hw_screen(true);
5381
5382 clear_keybuf();
5383 int32_t k = next_press_key();
5384 clear_keybuf();
5385
5386 //shnarf
5387 //47=f1
5388 //59=esc
5389 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5390 // *((int32_t*)d->dp3) = k;
5391 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5392
5393
5394 d->flags&=~D_SELECTED;
5395 }
5396
5397 //Clears key to 0.
5398 //Used by all keyboard key settings dialogues.
5399 void kb_clearkey(DIALOG *d);
5400
5401 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5402 {
5403 switch(msg)
5404 {
5405 case MSG_KEY:
5406 case MSG_CLICK:
5407
5408 kb_clearjoystick(d);
5409
5410 while(gui_mouse_b())
5411 {
5412 clear_keybuf();
5413 rest(1);
5414 }
5415
5416 return D_REDRAW;
5417 }
5418
5419 return jwin_button_proc(msg,d,c);
5420 }
5421
5422 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5423 //Only used in keyboard settings dialogues to clear keys.
5424 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5425
5426 void j_getbtn(DIALOG *d)
5427 {
5428 d->flags|=D_SELECTED;
5429 scare_mouse();
5430 jwin_button_proc(MSG_DRAW,d,0);
5431 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5432 // text_mode(vc(11));
5433 int32_t y = gui_bmp->h/2 - 12;
5434 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5435 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5436 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5437 unscare_mouse();
5438
5439 update_hw_screen(true);
5440
5441 int32_t b = next_press_btn();
5442
5443 if(b>=0)
5444 *((int32_t*)d->dp3) = b;
5445
5446 d->flags&=~D_SELECTED;
5447
5448 if (player)
5449 player->joy_on = TRUE;
5450 }
5451
5452 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5453 {
5454 switch(msg)
5455 {
5456 case MSG_KEY:
5457 case MSG_CLICK:
5458
5459 j_getbtn(d);
5460
5461 while(gui_mouse_b()) {
5462 rest(1);
5463 clear_keybuf();
5464 }
5465
5466 return D_REDRAW;
5467 }
5468
5469 return jwin_button_proc(msg,d,c);
5470 }
5471
5472 //shnarf
5473 extern const char *key_str[];
5474 std::string get_keystr(int key);
5475
5476 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5477 //extern int32_t zcmusic_bufsz;
5478
5479 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5480 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5481
5482 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5483 {
5484 //these are here to bypass compiler warnings about unused arguments
5485 c=c;
5486
5487 if(msg==MSG_DRAW)
5488 {
5489 switch(d->w)
5490 {
5491 case 0:
5492 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5493 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5494 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5495 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5496 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5497 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5498 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5499 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5500 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5501 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5502 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5503 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5504 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5505 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5506 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5507 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5508 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5509 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5510 break;
5511
5512 case 1:
5513 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5514 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5515 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5516 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5517 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5518 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5519 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5520 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5521 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5522 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5523 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5524 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5525 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5526 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5527 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5528 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5529 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5530 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5531 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5532 break;
5533
5534 case 2:
5535 sprintf(str_a," %3d",midi_volume);
5536 sprintf(str_b," %3d",digi_volume);
5537 sprintf(str_l," %3d",emusic_volume);
5538 sprintf(str_m," %3dKB",zcmusic_bufsz);
5539 sprintf(str_r," %3d",sfx_volume);
5540 strcpy(str_s,pan_str[pan_style]);
5541 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5542 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5543 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5544 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5545 break;
5546 }
5547 }
5548
5549 return D_O_K;
5550 }
5551
5552 int32_t set_vol(void *dp3, int32_t d2)
5553 {
5554 switch(((int32_t*)dp3)[0])
5555 {
5556 case 0:
5557 midi_volume = zc_min(d2<<3,255);
5558 break;
5559
5560 case 1:
5561 digi_volume = zc_min(d2<<3,255);
5562 break;
5563
5564 case 2:
5565 emusic_volume = zc_min(d2<<3,255);
5566 break;
5567
5568 case 3:
5569 sfx_volume = zc_min(d2<<3,255);
5570 break;
5571 }
5572
5573 scare_mouse();
5574 // text_mode(vc(11));
5575 textprintf_right_ex(screen,lfont_l, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5576 unscare_mouse();
5577 return D_O_K;
5578 }
5579
5580 int32_t set_pan(void *dp3, int32_t d2)
5581 {
5582 pan_style = vbound(d2,0,3);
5583 scare_mouse();
5584 // text_mode(vc(11));
5585 textout_right_ex(screen,lfont_l, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5586 unscare_mouse();
5587 return D_O_K;
5588 }
5589
5590 int32_t set_buf(void *dp3, int32_t d2)
5591 {
5592 scare_mouse();
5593 // text_mode(vc(11));
5594 zcmusic_bufsz = d2 + 1;
5595 textprintf_right_ex(screen,lfont_l, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5596 unscare_mouse();
5597 return D_O_K;
5598 }
5599
5600 static int32_t gamepad_btn_list[] =
5601 {
5602 6,
5603 7,8,9,10,11,12,13,14,15,16,17,
5604 18,19,20,21,22,23,24,25,26,27,28,
5605 29,30,31,32,33,34,35,36,37,38,39,
5606 -1
5607 };
5608
5609 static int32_t gamepad_dirs_list[] =
5610 {
5611 40,41,42,43,
5612 44,45,46,47,
5613 48,49,50,51,
5614 52,53,54,55,
5615 56,
5616 -1
5617 };
5618
5619 static TABPANEL gamepad_tabs[] =
5620 {
5621 // (text)
5622 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5623 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5624 { NULL, 0, NULL, 0, NULL }
5625 };
5626
5627 static DIALOG gamepad_dlg[] =
5628 {
5629 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5630 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5631 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5632 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5633 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5634 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5635 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5636 // 6
5637 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5638 // 7
5639 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5640 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5641 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5642 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5643 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5644 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5645 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5646 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5647 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5648 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5649 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5650 // 18
5651 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5652 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5653 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5654 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5655 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5656 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5657 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5658 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5659 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5660 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5661 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5662 // 29
5663 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5664 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5665 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5666 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5667 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5668 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5669 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5670 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5671 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5672 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5673 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5674 // 40
5675 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5676 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5677 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5678 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5679 // 44
5680 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5681 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5682 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5683 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5684 // 48
5685 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5686 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5687 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5688 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5689 // 52
5690 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5691 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5692 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5693 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5694 // 56
5695 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5696 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5697 };
5698
5699 static int32_t keyboard_keys_list[] =
5700 {
5701 6,7,8,9,10,
5702 11,12,13,14,15,16,17,18,19,20,
5703 21,22,23,24,25,26,27,28,29,30,
5704 31,32,33,34,35,36,37,38,39,40,
5705 -1
5706 };
5707
5708 static int32_t keyboard_dirs_list[] =
5709 {
5710 41,42,43,44,
5711 45,46,47,48,
5712 49,50,51,52,
5713 53,54,55,56,
5714 -1
5715 };
5716
5717 static int32_t keyboard_mods_list[] =
5718 {
5719 57,58,59,60,
5720 61,62,63,64,
5721 65,66,67,68,
5722 69,70,71,72,
5723 -1
5724 };
5725
5726 static TABPANEL keyboard_control_tabs[] =
5727 {
5728 // (text)
5729 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5730 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5731 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5732 { NULL, 0, NULL, 0, NULL }
5733 };
5734
5735 static DIALOG keyboard_control_dlg[] =
5736 {
5737 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5738 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5739 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5740 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5741 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5742 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5743 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5744 // Keys
5745 // 6
5746 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5747 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5748 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5749 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5750 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5751 // 11
5752 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5753 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5754 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5755 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5756 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5757 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5758 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5759 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5760 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5761 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5762 // 21
5763 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5764 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5765 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5766 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5767 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5768 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5769 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5770 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5771 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5772 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5773 // 31
5774 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5775 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5776 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5777 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5778 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5779 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5780 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5781 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5782 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5783 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5784 // Dirs
5785 // 41
5786 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5787 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5788 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5789 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5790 // 45
5791 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5792 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5793 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5794 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5795 // 49
5796 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5797 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5798 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5799 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5800 // 53
5801 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5802 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5803 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5804 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5805 // Mods
5806 // 57
5807 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5808 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5809 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5810 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5811 // 61
5812 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5813 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5814 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5815 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5816 // 65
5817 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5818 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5819 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5820 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5821 // 69
5822 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5823 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5824 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5825 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5826 // 73
5827 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5828 };
5829
5830 /*
5831 int32_t midi_dp[3] = {0,147,104};
5832 int32_t digi_dp[3] = {1,147,120};
5833 int32_t pan_dp[3] = {0,147,136};
5834 int32_t buf_dp[3] = {0,147,152};
5835 */
5836 int32_t midi_dp[3] = {0,0,0};
5837 int32_t digi_dp[3] = {1,0,0};
5838 int32_t emus_dp[3] = {2,0,0};
5839 int32_t buf_dp[3] = {0,0,0};
5840 int32_t sfx_dp[3] = {3,0,0};
5841 int32_t pan_dp[3] = {0,0,0};
5842
5843 static DIALOG sound_dlg[] =
5844 {
5845 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5846 29 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5847 29 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5848 29 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5849 29 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5850 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5851 29 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5852 29 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5853 29 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5854 29 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5855 29 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5856 // 10
5857 29 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5858 29 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5859 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5860 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5861 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5862 29 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5863 29 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5864 29 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5865 29 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5866 29 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5867 //20
5868 29 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5869 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5870 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5871 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5872 29 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5873 29 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5874 29 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5875 29 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5876 29 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5877 29 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5878 //30
5879 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5880 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5881 29 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5882 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5883 };
5884
5885 char zc_builddate[80];
5886 char zc_aboutstr[80];
5887
5888 static DIALOG about_dlg[] =
5889 {
5890 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5891 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5892 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5893 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5894 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5895 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5896 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5897 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5898 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5899 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5900 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5901 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5902 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5903 };
5904
5905
5906 static DIALOG quest_dlg[] =
5907 {
5908 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5909 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5910 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5911 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5912 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5913 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5914 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5915 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5916 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5917 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5918 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5919 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5920 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5921 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5922 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5923 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5924 };
5925
5926 static DIALOG triforce_dlg[] =
5927 {
5928 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5929 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5930 // 1
5931 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5932 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5933 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5934 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5935 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5936 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5937 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5938 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5939 // 9
5940 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5941 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5942 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5943 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5944 };
5945
5946 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5947 {
5948 go();
5949 int32_t ret=0;
5950 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
5951 comeback();
5952 return ret != 0;
5953 }
5954
5955
5956 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5957 {
5958 if(def!=modulepath)
5959 strcpy(modulepath,def);
5960
5961 if(!usefilename)
5962 {
5963 int32_t i=(int32_t)strlen(modulepath);
5964
5965 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
5966 modulepath[i--]=0;
5967 }
5968
5969 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
5970 int32_t ret=0;
5971 int32_t sel=0;
5972
5973 if(list==NULL)
5974 {
5975 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
5976 }
5977 else
5978 {
5979 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
5980 }
5981
5982 return ret!=0;
5983 }
5984
5985 //The Dialogue that loads a ZMOD Module File
5986 int32_t zc_load_zmod_module_file()
5987 {
5988 if ( Playing )
5989 {
5990 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
5991 return -1;
5992 }
5993 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
5994 return D_CLOSE;
5995
5996 FILE *tempmodule = fopen(modulepath,"r");
5997
5998 if(tempmodule == NULL)
5999 {
6000 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6001 return -1;
6002 }
6003
6004
6005 //Set the module path:
6006 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6007 strcpy(moduledata.module_name, modulepath);
6008 al_trace("New Module Path is: %s \n", moduledata.module_name);
6009 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6010 zcm.init(true); //Load the module values.
6011 moduledata.refresh_title_screen = 1;
6012 // refresh_select_screen = 1;
6013 build_biic_list();
6014 return D_O_K;
6015 }
6016
6017 static DIALOG module_info_dlg[] =
6018 {
6019 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6020
6021
6022 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6023 //1
6024 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6025 //2
6026 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6027 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6028 //4
6029 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6030 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6031 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6032 //7
6033
6034 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6035 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6036 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6037 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6038 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6039 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6040 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6041 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6042 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6043
6044 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6045 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6046 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6047 };
6048
6049 void about_zcplayer_module(const char *prompt,int32_t initialval)
6050 {
6051
6052 module_info_dlg[0].dp2 = lfont;
6053 if ( moduledata.moduletitle[0] != 0 )
6054 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6055
6056 if ( moduledata.moduleauthor[0] != 0 )
6057 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6058
6059 if ( moduledata.moduleinfo0[0] != 0 )
6060 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6061 if ( moduledata.moduleinfo1[0] != 0 )
6062 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6063 if ( moduledata.moduleinfo2[0] != 0 )
6064 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6065 if ( moduledata.moduleinfo3[0] != 0 )
6066 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6067 if ( moduledata.moduleinfo4[0] != 0 )
6068 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6069
6070 char module_date[255];
6071 memset(module_date, 0, sizeof(module_date));
6072 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6073 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6074
6075
6076
6077 char module_vers[255];
6078 memset(module_vers, 0, sizeof(module_vers));
6079 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6080
6081
6082 //sprintf(tilecount,"%d",1);
6083
6084 char module_build[255];
6085 memset(module_build, 0, sizeof(module_build));
6086 if ( moduledata.modbeta )
6087 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6088 else
6089 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6090
6091 module_info_dlg[12].dp = (char*)module_date;
6092 module_info_dlg[13].dp = (char*)module_vers;
6093 module_info_dlg[14].dp = (char*)module_build;
6094
6095 large_dialog(module_info_dlg);
6096
6097 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6098 jwin_center_dialog(module_info_dlg);
6099
6100
6101 }
6102
6103 int32_t onAbout_ZCP_Module()
6104 {
6105 about_zcplayer_module("About Module (.zmod)", 0);
6106 return D_O_K;
6107 }
6108
6109 //New Modules Menu for 2.55+
6110 static MENU zcmodule_menu[] =
6111 {
6112 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6113 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6114
6115 { NULL, NULL, NULL, 0, NULL }
6116 };
6117
6118 int32_t onToggleRecordingNewSaves()
6119 {
6120 if (zc_get_config("zeldadx", "replay_new_saves", false))
6121 {
6122 zc_set_config("zeldadx", "replay_new_saves", false);
6123 }
6124 else
6125 {
6126 zc_set_config("zeldadx", "replay_new_saves", true);
6127 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6128 NULL,NULL,"OK",NULL,13,27,lfont);
6129 }
6130 return D_O_K;
6131 }
6132
6133 int32_t onToggleSnapshotAllFrames()
6134 {
6135 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6136 return D_O_K;
6137 }
6138
6139 int32_t onStopReplayOrRecord()
6140 {
6141 if (replay_is_replaying())
6142 {
6143 replay_quit();
6144 }
6145 else if (replay_get_mode() == ReplayMode::Record)
6146 {
6147 if (!replay_get_meta_bool("test_mode"))
6148 {
6149 jwin_alert("Recording", "You cannot stop recording a save file.",
6150 NULL,NULL,"OK",NULL,13,27,lfont);
6151 return D_CLOSE;
6152 }
6153
6154 if (jwin_alert("Stop Recording",
6155 "Save replay to disk and stop recording?",
6156 "This will stop the recording.",
6157 NULL,
6158 "Yes","No",13,27,lfont) != 1)
6159 return D_CLOSE;
6160
6161 replay_save();
6162 replay_stop();
6163 }
6164 return D_O_K;
6165 }
6166
6167 static int32_t handle_on_load_replay(ReplayMode mode)
6168 {
6169 if (Playing)
6170 {
6171 if (jwin_alert("Replay - Warning!",
6172 "Loading a replay will exit the current game.",
6173 "All unsaved progress will be lost.",
6174 "Do you wish to continue?",
6175 "Yes","No",13,27,lfont) != 1)
6176 return D_CLOSE;
6177 }
6178
6179 std::string mode_string = replay_mode_to_string(mode);
6180 mode_string[0] = std::toupper(mode_string[0]);
6181
6182 std::string line_1 = "Select a replay file to play back.";
6183 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6184 std::string line_3 = "You can stop the replay and take over manually any time.";
6185 if (mode == ReplayMode::Update)
6186 {
6187 line_1 = "Select a replay file to update.";
6188 line_2 = "WARNING: be sure to back up the zplay file";
6189 line_3 = "and verify that the updated replay works as expected!";
6190 }
6191
6192 if (jwin_alert(mode_string.c_str(),
6193 line_1.c_str(),
6194 line_2.c_str(),
6195 line_3.c_str(),
6196 "OK","Nevermind",13,27,lfont) == 1)
6197 {
6198 char replay_path[2048];
6199 strcpy(replay_path, "replays/");
6200 if (jwin_file_select_ex(
6201 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6202 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6203 return D_CLOSE;
6204
6205 replay_quit();
6206 load_replay_file_deferred(mode, replay_path);
6207 Quit = qRESET;
6208 return D_CLOSE;
6209 }
6210 return D_O_K;
6211 }
6212
6213 int32_t onLoadReplay()
6214 {
6215 return handle_on_load_replay(ReplayMode::Replay);
6216 }
6217
6218 int32_t onLoadReplayAssert()
6219 {
6220 return handle_on_load_replay(ReplayMode::Assert);
6221 }
6222
6223 int32_t onLoadReplayUpdate()
6224 {
6225 return handle_on_load_replay(ReplayMode::Update);
6226 }
6227
6228 int32_t onSaveReplay()
6229 {
6230 if (replay_get_mode() == ReplayMode::Record)
6231 {
6232 if (!replay_get_meta_bool("test_mode"))
6233 {
6234 if (jwin_alert("Save Replay",
6235 "This will save a copy of the replay up to this point.",
6236 "The official replay file will be untouched.",
6237 "Do you wish to continue?",
6238 "Yes","No",13,27,lfont) != 1)
6239 return D_CLOSE;
6240
6241 char replay_path[2048];
6242 strcpy(replay_path, replay_get_replay_path().string().c_str());
6243 if (jwin_file_select_ex(
6244 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6245 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6246 return D_CLOSE;
6247
6248 if (fileexists(replay_path))
6249 {
6250 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6251 NULL,NULL,"OK",NULL,13,27,lfont);
6252 return D_CLOSE;
6253 }
6254
6255 replay_save(replay_path);
6256 }
6257 else
6258 {
6259 replay_save();
6260 }
6261 }
6262 return D_O_K;
6263 }
6264
6265 static MENU replay_menu[] =
6266 {
6267 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6268 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6269 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6270 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6271 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6272 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6273 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6274
6275 { NULL, NULL, NULL, 0, NULL }
6276 };
6277
6278 static DIALOG credits_dlg[] =
6279 {
6280 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6281 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6282 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6283 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6284 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6285 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6286 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6287 };
6288
6289 29 static ListData dmap_list(dmaplist, &font);
6290
6291 static DIALOG goto_dlg[] =
6292 {
6293 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6294 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6295 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6296 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6297 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6298 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6299 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6300 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6301 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6302 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6303 };
6304
6305 int32_t onGoTo()
6306 {
6307 bool music = false;
6308 music = music;
6309 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6310
6311 goto_dlg[0].dp2=lfont;
6312 goto_dlg[4].d2=cheat_goto_dmap;
6313 goto_dlg[6].dp=cheat_goto_screen_str;
6314
6315 clear_keybuf();
6316
6317 large_dialog(goto_dlg);
6318
6319 if(zc_popup_dialog(goto_dlg,4)==1)
6320 {
6321 // dmap, screen
6322 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6323 };
6324
6325 return D_O_K;
6326 }
6327
6328 int32_t onGoToComplete()
6329 {
6330 if(!Playing)
6331 {
6332 return D_O_K;
6333 }
6334
6335 system_pal();
6336 music_pause();
6337 pause_all_sfx();
6338 show_mouse(screen);
6339 onGoTo();
6340 eat_buttons();
6341
6342 zc_readrawkey(KEY_ESC);
6343
6344 show_mouse(NULL);
6345 game_pal();
6346 music_resume();
6347 resume_all_sfx();
6348 return D_O_K;
6349 }
6350
6351 int32_t onCredits()
6352 {
6353 go();
6354
6355 BITMAP *win = create_bitmap_ex(8,222,110);
6356
6357 if(!win)
6358 return D_O_K;
6359
6360 int32_t c=0;
6361 int32_t l=0;
6362 int32_t ol=-1;
6363 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6364 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6365 PALETTE tmppal;
6366
6367 rti_gui.transparency_index = 1;
6368
6369 clear_to_color(win, rti_gui.transparency_index);
6370 draw_rle_sprite(win,rle,0,0);
6371 credits_dlg[0].dp2=lfont;
6372 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6373 credits_dlg[2].dp = win;
6374
6375 set_palette_range(black_palette,0,127,false);
6376
6377 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6378
6379 BITMAP* old_screen = screen;
6380 BITMAP* gui_bmp = zc_get_gui_bmp();
6381 ASSERT(gui_bmp);
6382 clear_to_color(gui_bmp, rti_gui.transparency_index);
6383 screen = gui_bmp;
6384
6385 while(update_dialog(p))
6386 {
6387 throttleFPS();
6388 ++c;
6389 l = zc_max((c>>1)-30,0);
6390
6391 if(l > rle->h)
6392 l = c = 0;
6393
6394 if(l > rle->h - 112)
6395 l = rle->h - 112;
6396
6397 clear_bitmap(win);
6398 draw_rle_sprite(win,rle,0,0-l);
6399
6400 if(c<=64)
6401 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6402
6403 set_palette_range(tmppal,0,127,false);
6404
6405 if(l!=ol)
6406 {
6407 scare_mouse();
6408 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6409 unscare_mouse();
6410 SCRFIX();
6411 ol=l;
6412 }
6413
6414 update_hw_screen();
6415 }
6416
6417 screen = old_screen;
6418 system_pal();
6419
6420 shutdown_dialog(p);
6421 destroy_bitmap(win);
6422 //comeback();
6423
6424 rti_gui.transparency_index = 0;
6425
6426 return D_O_K;
6427 }
6428
6429 const char *midilist(int32_t index, int32_t *list_size)
6430 {
6431 if(index<0)
6432 {
6433 *list_size=0;
6434
6435 for(int32_t i=0; i<MAXMIDIS; i++)
6436 if(tunes[i].data)
6437 ++(*list_size);
6438
6439 return NULL;
6440 }
6441
6442 int32_t i=0,m=0;
6443
6444 while(m<=index && i<=MAXMIDIS)
6445 {
6446 if(tunes[i].data)
6447 ++m;
6448
6449 ++i;
6450 }
6451
6452 --i;
6453
6454 if(i==MAXMIDIS && m<index)
6455 return "(null)";
6456
6457 return tunes[i].title;
6458 }
6459
6460 /* ------- MIDI info stuff -------- */
6461
6462 char *text;
6463 midi_info *zmi;
6464 bool dialog_running;
6465 bool listening;
6466
6467 void get_info(int32_t index);
6468
6469 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6470 {
6471 int32_t d2 = d->d2;
6472 int32_t ret = jwin_droplist_proc(msg,d,c);
6473
6474 if(d2!=d->d2)
6475 {
6476 get_info(d->d2);
6477 }
6478
6479 return ret;
6480 }
6481
6482 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6483 {
6484 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6485
6486 int32_t ret = jwin_button_proc(msg,d,c);
6487
6488 if(ret == D_CLOSE)
6489 {
6490 // get current midi index
6491 int32_t index = (d+(d->d1))->d2;
6492 int32_t i=0, m=0;
6493
6494 while(m<=index && i<=MAXMIDIS)
6495 {
6496 if(tunes[i].data)
6497 ++m;
6498
6499 ++i;
6500 }
6501
6502 --i;
6503 jukebox(i);
6504 listening = true;
6505 ret = D_O_K;
6506 }
6507
6508 return ret;
6509 }
6510
6511 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6512 {
6513 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6514
6515 int32_t ret = jwin_button_proc(msg,d,c);
6516
6517 if(ret == D_CLOSE)
6518 {
6519 // get current midi index
6520 int32_t index = (d+(d->d1))->d2;
6521 int32_t i=0, m=0;
6522
6523 while(m<=index && i<=MAXMIDIS)
6524 {
6525 if(tunes[i].data)
6526 ++m;
6527
6528 ++i;
6529 }
6530
6531 --i;
6532
6533 // get file name
6534
6535 int32_t sel=0;
6536 //struct ffblk f;
6537 char title[40] = "Save MIDI: ";
6538 char fname[2048];
6539 memset(fname,0,2048);
6540 static EXT_LIST list[] =
6541 {
6542 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6543 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6544 { NULL, NULL }
6545 };
6546
6547 strcpy(title+11, tunes[i].title);
6548 title[39] = '\0';
6549
6550 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6551 goto done;
6552
6553 if(exists(fname))
6554 {
6555 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6556 goto done;
6557 }
6558
6559 // save midi i
6560
6561 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6562 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6563
6564 done:
6565 chop_path(fname);
6566 ret = D_REDRAW;
6567 }
6568
6569 return ret;
6570 }
6571
6572 29 static ListData midi_list(midilist, &font);
6573
6574 static DIALOG midi_dlg[] =
6575 {
6576 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6577 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6578 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6579 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6580 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6581 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6582 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6583 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6584 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6585 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6586 };
6587
6588 void get_info(int32_t index)
6589 {
6590 int32_t i=0, m=0;
6591
6592 while(m<=index && i<=MAXMIDIS)
6593 {
6594 if(tunes[i].data)
6595 ++m;
6596
6597 ++i;
6598 }
6599
6600 --i;
6601
6602 if(i==MAXMIDIS && m<index)
6603 strcpy(text,"(null)");
6604 else
6605 {
6606 get_midi_info((MIDI*)tunes[i].data,zmi);
6607 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6608 }
6609
6610 midi_dlg[0].dp2=lfont;
6611 midi_dlg[3].dp = text;
6612 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6613 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6614
6615 if(dialog_running)
6616 {
6617 scare_mouse();
6618 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6619 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6620 unscare_mouse();
6621 }
6622 }
6623
6624 int32_t onMIDICredits()
6625 {
6626 text = (char*)malloc(4096);
6627 zmi = (midi_info*)malloc(sizeof(midi_info));
6628
6629 if(!text || !zmi)
6630 {
6631 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6632 return D_O_K;
6633 }
6634
6635 bool do_pause_midi = midi_pos >= 0 && currmidi;
6636 auto restore_midi = currmidi;
6637 if(do_pause_midi)
6638 {
6639 paused_midi_pos = midi_pos;
6640 stop_midi();
6641 midi_paused=true;
6642 midi_suspended = midissuspHALTED;
6643 }
6644
6645 midi_dlg[0].dp2=lfont;
6646 midi_dlg[2].d1 = 0;
6647 midi_dlg[2].d2 = 0;
6648 midi_dlg[4].flags = D_EXIT;
6649 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6650
6651 listening = false;
6652 dialog_running=false;
6653 get_info(0);
6654
6655 dialog_running=true;
6656
6657 large_dialog(midi_dlg);
6658
6659 zc_popup_dialog(midi_dlg,0);
6660 dialog_running=false;
6661
6662 if(listening)
6663 music_stop();
6664
6665 if(do_pause_midi)
6666 {
6667 midi_suspended = midissuspRESUME;
6668 currmidi = restore_midi;
6669 midi_pos = paused_midi_pos;
6670 }
6671
6672 if(text) free(text);
6673 if(zmi) free(zmi);
6674 return D_O_K;
6675 }
6676
6677 int32_t onAbout()
6678 {
6679 char buf1[80]={0};
6680 std::ostringstream oss;
6681 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6682 oss << buf1 << '\n';
6683 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6684 oss << buf1 << '\n';
6685 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6686 oss << buf1 << '\n';
6687 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6688 oss << buf1 << '\n';
6689 sprintf(buf1, "Tag: %s", getReleaseTag());
6690 oss << buf1 << '\n';
6691
6692 InfoDialog("About ZC", oss.str()).show();
6693 return D_O_K;
6694 }
6695
6696 int32_t onQuest()
6697 {
6698 char fname[100];
6699 strcpy(fname, get_filename(qstpath));
6700 quest_dlg[0].dp2=lfont;
6701 quest_dlg[1].dp = fname;
6702
6703 if(QHeader.quest_number==0)
6704 sprintf(str_a,"Custom");
6705 else
6706 sprintf(str_a,"%d",QHeader.quest_number);
6707
6708 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6709
6710 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6711 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6712
6713 large_dialog(quest_dlg);
6714
6715 zc_popup_dialog(quest_dlg, 0);
6716 return D_O_K;
6717 }
6718
6719 void call_vidmode_dlg();
6720 int32_t onVidMode()
6721 {
6722 call_vidmode_dlg();
6723 return D_O_K;
6724 }
6725
6726 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6727 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6728 //Added an extra statement, so that if the key is cleared to 0, the cleared
6729 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6730
6731 void load_ukeys(int32_t* arr)
6732 {
6733 arr[ukey_a] = Akey;
6734 arr[ukey_b] = Bkey;
6735 arr[ukey_s] = Skey;
6736 arr[ukey_l] = Lkey;
6737 arr[ukey_r] = Rkey;
6738 arr[ukey_p] = Pkey;
6739 arr[ukey_ex1] = Exkey1;
6740 arr[ukey_ex2] = Exkey2;
6741 arr[ukey_ex3] = Exkey3;
6742 arr[ukey_ex4] = Exkey4;
6743 arr[ukey_du] = DUkey;
6744 arr[ukey_dd] = DDkey;
6745 arr[ukey_dl] = DLkey;
6746 arr[ukey_dr] = DRkey;
6747 arr[ukey_mod1a] = cheat_modifier_keys[0];
6748 arr[ukey_mod1b] = cheat_modifier_keys[1];
6749 arr[ukey_mod2a] = cheat_modifier_keys[2];
6750 arr[ukey_mod2b] = cheat_modifier_keys[3];
6751 };
6752
6753 static const char* ukey_names[] = {
6754 "A", "B", "Start", "L", "R", "Map",
6755 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6756 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6757 "Cheat Mod R1", "Cheat Mod R2",
6758 };
6759 std::string get_ukey_name(int32_t k)
6760 {
6761 if (k < num_ukey) return ukey_names[k];
6762 return "";
6763 }
6764
6765 int32_t onKeyboard()
6766 {
6767 int32_t a = Akey;
6768 int32_t b = Bkey;
6769 int32_t s = Skey;
6770 int32_t l = Lkey;
6771 int32_t r = Rkey;
6772 int32_t p = Pkey;
6773 int32_t ex1 = Exkey1;
6774 int32_t ex2 = Exkey2;
6775 int32_t ex3 = Exkey3;
6776 int32_t ex4 = Exkey4;
6777 int32_t du = DUkey;
6778 int32_t dd = DDkey;
6779 int32_t dl = DLkey;
6780 int32_t dr = DRkey;
6781 int32_t mod1a = cheat_modifier_keys[0];
6782 int32_t mod1b = cheat_modifier_keys[1];
6783 int32_t mod2a = cheat_modifier_keys[2];
6784 int32_t mod2b = cheat_modifier_keys[3];
6785 bool done=false;
6786 int32_t ret;
6787
6788 keyboard_control_dlg[0].dp2=lfont;
6789
6790 large_dialog(keyboard_control_dlg);
6791
6792 while(!done)
6793 {
6794 ret = zc_popup_dialog(keyboard_control_dlg,3);
6795
6796 if(ret==3) // OK
6797 {
6798 int32_t ukeys[num_ukey];
6799 load_ukeys(ukeys);
6800 std::vector<std::string> uniqueError;
6801 for(int32_t q = 0; q < num_ukey; ++q)
6802 {
6803 for(int32_t p = q+1; p < num_ukey; ++p)
6804 {
6805 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6806 {
6807 char buf[64];
6808 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6809 std::string str(buf);
6810 uniqueError.push_back(str);
6811 }
6812 }
6813 }
6814 if(uniqueError.size() == 0)
6815 {
6816 done = true;
6817 save_control_configs(true);
6818 }
6819 else
6820 {
6821 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6822 box_out("Cannot have duplicate keybinds!"); box_eol();
6823 for(std::vector<std::string>::iterator it = uniqueError.begin();
6824 it != uniqueError.end(); ++it)
6825 {
6826 box_out((*it).c_str()); box_eol();
6827 }
6828 box_end(true);
6829 }
6830 }
6831 else // Cancel
6832 {
6833 Akey = a;
6834 Bkey = b;
6835 Skey = s;
6836 Lkey = l;
6837 Rkey = r;
6838 Pkey = p;
6839 Exkey1 = ex1;
6840 Exkey2 = ex2;
6841 Exkey3 = ex3;
6842 Exkey4 = ex4;
6843 DUkey = du;
6844 DDkey = dd;
6845 DLkey = dl;
6846 DRkey = dr;
6847 cheat_modifier_keys[0] = mod1a;
6848 cheat_modifier_keys[1] = mod1b;
6849 cheat_modifier_keys[2] = mod2a;
6850 cheat_modifier_keys[3] = mod2b;
6851
6852 done=true;
6853 }
6854
6855 rest(1);
6856 }
6857
6858 return D_O_K;
6859 }
6860
6861 int32_t onGamepad()
6862 {
6863 int32_t a = Abtn;
6864 int32_t b = Bbtn;
6865 int32_t s = Sbtn;
6866 int32_t l = Lbtn;
6867 int32_t r = Rbtn;
6868 int32_t m = Mbtn;
6869 int32_t p = Pbtn;
6870 int32_t ex1 = Exbtn1;
6871 int32_t ex2 = Exbtn2;
6872 int32_t ex3 = Exbtn3;
6873 int32_t ex4 = Exbtn4;
6874 int32_t up = DUbtn;
6875 int32_t down = DDbtn;
6876 int32_t left = DLbtn;
6877 int32_t right = DRbtn;
6878
6879 gamepad_dlg[0].dp2=lfont;
6880 if(analog_movement)
6881 gamepad_dlg[56].flags|=D_SELECTED;
6882 else
6883 gamepad_dlg[56].flags&=~D_SELECTED;
6884
6885 large_dialog(gamepad_dlg);
6886
6887 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
6888
6889 if(ret == 4) //OK
6890 {
6891 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6892 save_control_configs(false);
6893 }
6894 else //Cancel
6895 {
6896 Abtn = a;
6897 Bbtn = b;
6898 Sbtn = s;
6899 Lbtn = l;
6900 Rbtn = r;
6901 Mbtn = m;
6902 Pbtn = p;
6903 Exbtn1 = ex1;
6904 Exbtn2 = ex2;
6905 Exbtn3 = ex3;
6906 Exbtn4 = ex4;
6907 DUbtn = up;
6908 DDbtn = down;
6909 DLbtn = left;
6910 DRbtn = right;
6911 }
6912
6913 return D_O_K;
6914 }
6915
6916 int32_t onCheatKeys()
6917 {
6918 int32_t oldcheats[Cheat::Last][2];
6919 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6920
6921 bool done=false;
6922
6923 while(!done)
6924 {
6925 bool confirm = false;
6926 CheatKeysDialog(&confirm).show();
6927 if(confirm) // OK
6928 {
6929 std::vector<std::string> uniqueError;
6930 char buf[512];
6931 for(size_t q = 1; q < Cheat::Last; ++q)
6932 {
6933 if(cheatkeys[q][1] && !cheatkeys[q][0])
6934 {
6935 cheatkeys[q][0] = cheatkeys[q][1];
6936 cheatkeys[q][1] = 0;
6937 }
6938 }
6939 for(size_t q = 1; q < Cheat::Last; ++q)
6940 {
6941 if(!bindable_cheat((Cheat)q)) continue;
6942 for(size_t p = q+1; p < Cheat::Last; ++p)
6943 {
6944 if(!bindable_cheat((Cheat)p)) continue;
6945 for(size_t q2 = 0; q2 <= 1; ++q2)
6946 for(size_t p2 = 0; p2 <= 1; ++p2)
6947 {
6948 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6949 {
6950 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6951 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6952 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6953 get_keystr(cheatkeys[q][q2])));
6954 }
6955 }
6956 }
6957 }
6958 if(uniqueError.size() == 0)
6959 {
6960 done = true;
6961 save_cheatkeys();
6962 }
6963 else
6964 {
6965 box_start(1, "Duplicate Keys", lfont, sfont, false, 500,400, 2);
6966 box_out("Cannot have duplicate keybinds!"); box_eol();
6967 for(std::vector<std::string>::iterator it = uniqueError.begin();
6968 it != uniqueError.end(); ++it)
6969 {
6970 box_out((*it).c_str()); box_eol();
6971 }
6972 box_end(true);
6973 }
6974 }
6975 else // Cancel
6976 {
6977 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6978 done=true;
6979 }
6980 rest(1);
6981 }
6982
6983 return D_O_K;
6984 }
6985
6986 int32_t onSound()
6987 {
6988 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
6989 {
6990 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
6991 }
6992 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
6993 {
6994 master_volume((int32_t)(FFCore.usr_digi_volume),1);
6995 }
6996 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
6997 {
6998 emusic_volume = (int32_t)FFCore.usr_music_volume;
6999 }
7000 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7001 {
7002 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7003 }
7004 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7005 {
7006 pan_style = (int32_t)FFCore.usr_panstyle;
7007 }
7008
7009 int32_t m = midi_volume;
7010 int32_t d = digi_volume;
7011 int32_t e = emusic_volume;
7012 int32_t b = zcmusic_bufsz;
7013 int32_t s = sfx_volume;
7014 int32_t p = pan_style;
7015 pan_style = vbound(pan_style,0,3);
7016
7017 sound_dlg[0].dp2=lfont;
7018
7019 large_dialog(sound_dlg);
7020
7021 midi_dp[1] = sound_dlg[6].x;
7022 midi_dp[2] = sound_dlg[6].y;
7023 digi_dp[1] = sound_dlg[7].x;
7024 digi_dp[2] = sound_dlg[7].y;
7025 emus_dp[1] = sound_dlg[8].x;
7026 emus_dp[2] = sound_dlg[8].y;
7027 buf_dp[1] = sound_dlg[9].x;
7028 buf_dp[2] = sound_dlg[9].y;
7029 sfx_dp[1] = sound_dlg[10].x;
7030 sfx_dp[2] = sound_dlg[10].y;
7031 pan_dp[1] = sound_dlg[11].x;
7032 pan_dp[2] = sound_dlg[11].y;
7033 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7034 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7035 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7036 sound_dlg[18].d2 = zcmusic_bufsz;
7037 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7038 sound_dlg[20].d2 = pan_style;
7039
7040 int32_t ret = zc_popup_dialog(sound_dlg,1);
7041
7042 if(ret==2)
7043 {
7044 master_volume(digi_volume,midi_volume);
7045
7046 for(int32_t i=0; i<WAV_COUNT; ++i)
7047 {
7048 //allegro assertion fails when passing in -1 as voice -DD
7049 if(sfx_voice[i] > 0)
7050 voice_set_volume(sfx_voice[i], sfx_volume);
7051 }
7052 zc_set_config(sfx_sect,"digi",digi_volume);
7053 zc_set_config(sfx_sect,"midi",midi_volume);
7054 zc_set_config(sfx_sect,"sfx",sfx_volume);
7055 zc_set_config(sfx_sect,"emusic",emusic_volume);
7056 zc_set_config(sfx_sect,"pan",pan_style);
7057 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7058 }
7059 else
7060 {
7061 midi_volume = m;
7062 digi_volume = d;
7063 emusic_volume = e;
7064 zcmusic_bufsz = b;
7065 sfx_volume = s;
7066 pan_style = p;
7067 }
7068
7069 return D_O_K;
7070 }
7071
7072 int32_t queding(char const* s1, char const* s2, char const* s3)
7073 {
7074 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7075 }
7076
7077 int32_t onQuit()
7078 {
7079 if(Playing)
7080 {
7081 int32_t ret=0;
7082
7083 if(get_bit(quest_rules, qr_NOCONTINUE))
7084 {
7085 if(standalone_mode)
7086 {
7087 ret=queding("End current game?",
7088 "The continue screen is disabled; the game",
7089 "will be reloaded from the last save.");
7090 }
7091 else
7092 {
7093 ret=queding("End current game?",
7094 "The continue screen is disabled. You will",
7095 "be returned to the file select screen.");
7096 }
7097 }
7098 else
7099 ret=queding("End current game?",NULL,NULL);
7100
7101 if(ret==1)
7102 {
7103 disableClickToFreeze=false;
7104 Quit=qQUIT;
7105
7106 // Trying to evade a door repair charge?
7107 if(repaircharge)
7108 {
7109 game->change_drupy(-repaircharge);
7110 repaircharge=0;
7111 }
7112
7113 return D_CLOSE;
7114 }
7115 }
7116
7117 return D_O_K;
7118 }
7119
7120 int32_t onTryQuitMenu()
7121 {
7122 return onTryQuit(true);
7123 }
7124
7125 int32_t onTryQuit(bool inMenu)
7126 {
7127 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7128 {
7129 if(get_bit(quest_rules,qr_OLD_F6))
7130 {
7131 if(inMenu) onQuit();
7132 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7133 }
7134 else
7135 {
7136 disableClickToFreeze=false;
7137 GameFlags |= GAMEFLAG_TRYQUIT;
7138 }
7139 return D_CLOSE;
7140 }
7141
7142 return D_O_K;
7143 }
7144
7145 int32_t onReset()
7146 {
7147 if(queding(" Reset system? ",NULL,NULL)==1)
7148 {
7149 disableClickToFreeze=false;
7150 Quit=qRESET;
7151 replay_quit();
7152 return D_CLOSE;
7153 }
7154
7155 return D_O_K;
7156 }
7157
7158 int32_t onExit()
7159 {
7160 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7161 {
7162 Quit=qEXIT;
7163 return D_CLOSE;
7164 }
7165
7166 return D_O_K;
7167 }
7168
7169 int32_t onTitle_NES()
7170 {
7171 title_version=0;
7172 zc_set_config(cfg_sect,"title",title_version);
7173 return D_O_K;
7174 }
7175 int32_t onTitle_DX()
7176 {
7177 title_version=1;
7178 zc_set_config(cfg_sect,"title",title_version);
7179 return D_O_K;
7180 }
7181 int32_t onTitle_25()
7182 {
7183 title_version=2;
7184 zc_set_config(cfg_sect,"title",title_version);
7185 return D_O_K;
7186 }
7187
7188 int32_t onDebug()
7189 {
7190 if(debug_enabled)
7191 set_debug(!get_debug());
7192 return D_O_K;
7193 }
7194
7195 int32_t onHeartBeep()
7196 {
7197 heart_beep=!heart_beep;
7198 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7199 return D_O_K;
7200 }
7201
7202 int32_t onSaveIndicator()
7203 {
7204 use_save_indicator=!use_save_indicator;
7205 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7206 return D_O_K;
7207 }
7208
7209 int32_t onEpilepsy()
7210 {
7211 if(jwin_alert3(
7212 "Epilepsy Flash Reduction",
7213 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7214 "Disabling this will restore standard flash and wavy behaviour.",
7215 "Proceed?",
7216 "&Yes",
7217 "&No",
7218 NULL,
7219 'y',
7220 'n',
7221 0,
7222 lfont) == 1)
7223 {
7224 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7225 zc_set_config("zeldadx","checked_epilepsy",1);
7226 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7227 }
7228 return D_O_K;
7229 }
7230
7231 int32_t onTriforce()
7232 {
7233 for(int32_t i=0; i<MAXINITTABS; ++i)
7234 {
7235 init_tabs[i].flags&=~D_SELECTED;
7236 }
7237
7238 init_tabs[3].flags=D_SELECTED;
7239 return onCheatConsole();
7240 /*triforce_dlg[0].dp2=lfont;
7241 for(int32_t i=1; i<=8; i++)
7242 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7243
7244 if(zc_popup_dialog (triforce_dlg,-1)==9)
7245 {
7246 for(int32_t i=1; i<=8; i++)
7247 {
7248 game->lvlitems[i] &= ~liTRIFORCE;
7249 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7250 }
7251 }
7252 return D_O_K;*/
7253 }
7254
7255 bool rc = false;
7256 /*
7257 int32_t onEquipment()
7258 {
7259 for (int32_t i=0; i<MAXINITTABS; ++i)
7260 {
7261 init_tabs[i].flags&=~D_SELECTED;
7262 }
7263 init_tabs[0].flags=D_SELECTED;
7264 return onCheatConsole();
7265 }
7266 */
7267
7268 int32_t onItems()
7269 {
7270 for(int32_t i=0; i<MAXINITTABS; ++i)
7271 {
7272 init_tabs[i].flags&=~D_SELECTED;
7273 }
7274
7275 init_tabs[1].flags=D_SELECTED;
7276 return onCheatConsole();
7277 }
7278
7279 static DIALOG getnum_dlg[] =
7280 {
7281 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7282 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7283 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7284 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7285 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7286 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7287 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7288 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7289 };
7290
7291 int32_t getnumber(const char *prompt,int32_t initialval)
7292 {
7293 char buf[20];
7294 sprintf(buf,"%d",initialval);
7295 getnum_dlg[0].dp=(void *)prompt;
7296 getnum_dlg[0].dp2=lfont;
7297 getnum_dlg[2].dp=buf;
7298
7299 large_dialog(getnum_dlg);
7300
7301 if(zc_popup_dialog(getnum_dlg,2)==3)
7302 return atoi(buf);
7303
7304 return initialval;
7305 }
7306
7307 int32_t onLife()
7308 {
7309 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7310 cheats_enqueue(Cheat::Life, value);
7311 return D_O_K;
7312 }
7313
7314 int32_t onHeartC()
7315 {
7316 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7317 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7318 cheats_enqueue(Cheat::MaxLife, max_life);
7319 cheats_enqueue(Cheat::Life, life);
7320 return D_O_K;
7321 }
7322
7323 int32_t onMagicC()
7324 {
7325 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7326 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7327 cheats_enqueue(Cheat::MaxMagic, max_magic);
7328 cheats_enqueue(Cheat::Magic, magic);
7329 return D_O_K;
7330 }
7331
7332 int32_t onRupies()
7333 {
7334 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7335 cheats_enqueue(Cheat::Rupies, value);
7336 return D_O_K;
7337 }
7338
7339 int32_t onMaxBombs()
7340 {
7341 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7342 cheats_enqueue(Cheat::MaxBombs, value);
7343 cheats_enqueue(Cheat::Bombs, value);
7344 return D_O_K;
7345 }
7346
7347 int32_t onRefillLife()
7348 {
7349 cheats_enqueue(Cheat::Life, game->get_maxlife());
7350 return D_O_K;
7351 }
7352 int32_t onRefillMagic()
7353 {
7354 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7355 return D_O_K;
7356 }
7357 int32_t onClock()
7358 {
7359 cheats_enqueue(Cheat::Clock);
7360 return D_O_K;
7361 }
7362
7363 int32_t onQstPath()
7364 {
7365 char path[2048];
7366
7367 chop_path(qstdir);
7368 strcpy(path,qstdir);
7369
7370 go();
7371
7372 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7373 {
7374 chop_path(path);
7375 fix_filename_case(path);
7376 fix_filename_slashes(path);
7377 strcpy(qstdir,path);
7378 strcpy(qstpath,qstdir);
7379 }
7380
7381 comeback();
7382 return D_O_K;
7383 }
7384
7385 #include "dialog/cheat_dialog.h"
7386 int32_t onCheat()
7387 {
7388 call_setcheat_dialog();
7389 game->set_cheat(maxcheat);
7390 if(cheat) game->did_cheat(true);
7391 return D_O_K;
7392 }
7393
7394 int32_t onCheatRupies()
7395 {
7396 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7397 return D_O_K;
7398 }
7399
7400 int32_t onCheatArrows()
7401 {
7402 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7403 return D_O_K;
7404 }
7405
7406 int32_t onCheatBombs()
7407 {
7408 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7409 return D_O_K;
7410 }
7411
7412 // *** screen saver
7413
7414 6510614 int32_t after_time()
7415 {
7416
1/2
✓ Branch 0 taken 6510614 times.
✗ Branch 1 not taken.
6510614 if(ss_enable == 0)
7417 return INT_MAX;
7418
7419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 0)
7420 return 5 * 60;
7421
7422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 3)
7423 return ss_after * 15 * 60;
7424
7425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510614 times.
6510614 if(ss_after <= 13)
7426 return (ss_after - 3) * 60 * 60;
7427
7428 6510614 return MAX_IDLE + 1;
7429 6510614 }
7430
7431 static const char *after_str[15] =
7432 {
7433 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7434 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7435 "Never"
7436 };
7437
7438 const char *after_list(int32_t index, int32_t *list_size)
7439 {
7440 if(index < 0)
7441 {
7442 *list_size = 15;
7443 return NULL;
7444 }
7445
7446 return after_str[index];
7447 }
7448
7449 29 static ListData after__list(after_list, &font);
7450
7451 static DIALOG scrsaver_dlg[] =
7452 {
7453 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7454 29 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7455 29 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7456 29 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7457 29 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7458 29 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7459 29 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7460 29 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7461 29 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7462 29 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7463 29 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7464 29 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7465 29 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7466 29 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7467 };
7468
7469 int32_t onScreenSaver()
7470 {
7471 scrsaver_dlg[0].dp2=lfont;
7472 int32_t oldcfgs[3];
7473 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7474 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7475 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7476
7477 large_dialog(scrsaver_dlg);
7478
7479 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7480
7481 if(ret == 8 || ret == 9)
7482 {
7483 ss_after = scrsaver_dlg[5].d1;
7484 ss_speed = scrsaver_dlg[6].d2;
7485 ss_density = scrsaver_dlg[7].d2;
7486 if(oldcfgs[0] != ss_after)
7487 zc_set_config(cfg_sect,"ss_after",ss_after);
7488 if(oldcfgs[1] != ss_speed)
7489 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7490 if(oldcfgs[2] != ss_density)
7491 zc_set_config(cfg_sect,"ss_density",ss_density);
7492 }
7493
7494 if(ret == 9)
7495 // preview Screen Saver
7496 {
7497 clear_keybuf();
7498 scare_mouse();
7499 Matrix(ss_speed, ss_density, 30);
7500 system_pal();
7501 unscare_mouse();
7502 }
7503
7504 return D_O_K;
7505 }
7506
7507 /***** Menus *****/
7508
7509 static MENU game_menu[] =
7510 {
7511 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7512 { (char *)"", NULL, NULL, 0, NULL },
7513 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7514 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7515 { (char *)"", NULL, NULL, 0, NULL },
7516 #ifdef __EMSCRIPTEN__
7517 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7518 #elif defined(ALLEGRO_MACOSX)
7519 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7520 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7521 #else
7522 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7523 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7524 #endif
7525 { NULL, NULL, NULL, 0, NULL }
7526 };
7527
7528 static MENU title_menu[] =
7529 {
7530 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7531 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7532 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7533 { NULL, NULL, NULL, 0, NULL }
7534 };
7535
7536 static MENU snapshot_format_menu[] =
7537 {
7538 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7539 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7540 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7541 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7542 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7543 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7544 { NULL, NULL, NULL, 0, NULL }
7545 };
7546
7547 static MENU controls_menu[] =
7548 {
7549 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7550 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7551 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7552 { NULL, NULL, NULL, 0, NULL }
7553 };
7554
7555 static MENU name_entry_mode_menu[] =
7556 {
7557 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7558 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7559 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7560 { NULL, NULL, NULL, 0, NULL }
7561 };
7562
7563 static void set_controls_menu_active()
7564 {
7565
7566 }
7567
7568 static MENU settings_menu[] =
7569 {
7570 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7571 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7572 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7573 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7574 { (char *)"", NULL, NULL, 0, NULL },
7575 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7576 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7577 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7578 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7579 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7580 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7581 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7582 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7583 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7584 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7585 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7586 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7587 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7588 { (char *)"", NULL, NULL, 0, NULL },
7589 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7590 { (char *)"", NULL, NULL, 0, NULL },
7591 { NULL, NULL, NULL, 0, NULL }
7592 };
7593
7594
7595 static MENU misc_menu[] =
7596 {
7597 { (char *)"&About...", onAbout, NULL, 0, NULL },
7598 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7599 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7600 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7601 { (char *)"", NULL, NULL, 0, NULL },
7602 //5
7603 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7604 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7605 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7606 { (char *)"", NULL, NULL, 0, NULL },
7607 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7608 //10
7609 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7610 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7611 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7612 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7613 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7614 //15
7615 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7616 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7617 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7618
7619 { NULL, NULL, NULL, 0, NULL }
7620 };
7621
7622 static MENU refill_menu[] =
7623 {
7624 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7625 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7626 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7627 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7628 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7629 { NULL, NULL, NULL, 0, NULL }
7630 };
7631
7632 static MENU show_menu[] =
7633 {
7634 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7635 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7636 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7637 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7638 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7639 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7640 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7641 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7642 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7643 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7644 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7645 { (char *)"", NULL, NULL, 0, NULL },
7646 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7647 { (char *)"", NULL, NULL, 0, NULL },
7648 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7649 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7650 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7651 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7652 { NULL, NULL, NULL, 0, NULL }
7653 };
7654
7655 static MENU cheat_menu[] =
7656 {
7657 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7658 { (char *)"", NULL, NULL, 0, NULL },
7659 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7660 { (char *)"", NULL, NULL, 0, NULL },
7661 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7662 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7663 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7664 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7665 { (char *)"", NULL, NULL, 0, NULL },
7666 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7667 { (char *)"", NULL, NULL, 0, NULL },
7668 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7669 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7670 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7671 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7672 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7673 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7674 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7675 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7676 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7677 { NULL, NULL, NULL, 0, NULL }
7678 };
7679
7680 static MENU fixes_menu[] =
7681 {
7682 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7683 { NULL, NULL, NULL, 0, NULL }
7684 };
7685
7686 #if DEVLEVEL > 0
7687 int32_t devLogging();
7688 int32_t devDebug();
7689 int32_t devTimestmp();
7690 #if DEVLEVEL > 1
7691 int32_t setCheat();
7692 #endif //DEVLEVEL > 1
7693 enum
7694 {
7695 dv_log,
7696 // dv_dbg,
7697 dv_tmpstmp,
7698 #if DEVLEVEL > 1
7699 dv_nil,
7700 dv_setcheat,
7701 #endif //DEVLEVEL > 1
7702 dv_max
7703 };
7704 static MENU dev_menu[] =
7705 {
7706 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7707 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7708 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7709 #if DEVLEVEL > 1
7710 { (char *)"", NULL, NULL, 0, NULL },
7711 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7712 #endif //DEVLEVEL > 1
7713 { NULL, NULL, NULL, 0, NULL }
7714 };
7715 int32_t devLogging()
7716 {
7717 dev_logging = !dev_logging;
7718 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7719 return D_O_K;
7720 }
7721 // int32_t devDebug()
7722 // {
7723 // dev_debug = !dev_debug;
7724 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7725 // return D_O_K;
7726 // }
7727 int32_t devTimestmp()
7728 {
7729 dev_timestmp = !dev_timestmp;
7730 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7731 return D_O_K;
7732 }
7733 #if DEVLEVEL > 1
7734 int32_t setCheat()
7735 {
7736 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7737 return D_O_K;
7738 }
7739 #endif //DEVLEVEL > 1
7740 #endif //DEVLEVEL > 0
7741
7742 MENU the_player_menu[] =
7743 {
7744 { (char *)"&Game", NULL, game_menu, 0, NULL },
7745 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7746 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7747 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
7748 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7749 #if DEVLEVEL > 0
7750 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7751 #endif
7752 { NULL, NULL, NULL, 0, NULL }
7753 };
7754
7755 MENU the_player_menu2[] =
7756 {
7757 { (char *)"&Game", NULL, game_menu, 0, NULL },
7758 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7759 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
7760 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7761 #if DEVLEVEL > 0
7762 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7763 #endif
7764 { NULL, NULL, NULL, 0, NULL }
7765 };
7766
7767 int32_t onMIDIPatch()
7768 {
7769 if(jwin_alert3(
7770 "Toggle Windows MIDI Fix",
7771 "This action will change whether ZC Player auto-restarts a MIDI at its",
7772 "last index if you move ZC Player out of focus, then back into focus.",
7773 "Proceed?",
7774 "&Yes",
7775 "&No",
7776 NULL,
7777 'y',
7778 'n',
7779 0,
7780 lfont) == 1)
7781 {
7782 midi_patch_fix = midi_patch_fix ? 0 : 1;
7783 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
7784 }
7785 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
7786 return D_O_K;
7787 }
7788
7789 int32_t onKeyboardEntry()
7790 {
7791 NameEntryMode=0;
7792 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7793 return D_O_K;
7794 }
7795
7796 int32_t onLetterGridEntry()
7797 {
7798 NameEntryMode=1;
7799 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7800 return D_O_K;
7801 }
7802
7803 int32_t onExtLetterGridEntry()
7804 {
7805 NameEntryMode=2;
7806 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7807 return D_O_K;
7808 }
7809
7810 static BITMAP* oldscreen;
7811 int32_t onFullscreenMenu()
7812 {
7813 // super hacks
7814 screen = oldscreen;
7815 if (onFullscreen() == D_REDRAW)
7816 {
7817 oldscreen = screen;
7818 }
7819 screen = menu_bmp;
7820 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7821 return D_O_K;
7822 }
7823
7824 29 void fix_menu()
7825 {
7826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if(!debug_enabled)
7827 29 settings_menu[18].text = NULL;
7828 29 }
7829
7830 static DIALOG system_dlg[] =
7831 {
7832 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7833 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7834 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7835 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7836 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7837 #ifndef ALLEGRO_MACOSX
7838 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7839 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7840 #else
7841 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7842 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7843 #endif
7844 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7845 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7846 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7847 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7848 };
7849
7850 static DIALOG system_dlg2[] =
7851 {
7852 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7853 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
7854 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7855 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7856 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7857 #ifndef ALLEGRO_MACOSX
7858 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7859 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7860 #else
7861 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7862 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7863 #endif
7864 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7865 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7866 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7867 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7868 };
7869
7870 void reset_snapshot_format_menu()
7871 {
7872 for(int32_t i=0; i<ssfmtMAX; ++i)
7873 {
7874 snapshot_format_menu[i].flags=0;
7875 }
7876 }
7877
7878 int32_t onSetSnapshotFormat()
7879 {
7880 switch(active_menu->text[1])
7881 {
7882 case 'B': //"&BMP"
7883 SnapshotFormat=0;
7884 break;
7885
7886 case 'G': //"&GIF"
7887 SnapshotFormat=1;
7888 break;
7889
7890 case 'J': //"&JPG"
7891 SnapshotFormat=2;
7892 break;
7893
7894 case 'P': //"&PNG"
7895 SnapshotFormat=3;
7896 break;
7897
7898 case 'C': //"PC&X"
7899 SnapshotFormat=4;
7900 break;
7901
7902 case 'T': //"&TGA"
7903 SnapshotFormat=5;
7904 break;
7905
7906 case 'L': //"&LBM"
7907 SnapshotFormat=6;
7908 break;
7909 }
7910 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7911
7912 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7913 return D_O_K;
7914 }
7915
7916
7917 43 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7918 {
7919 PALETTE tmp;
7920
7921
2/2
✓ Branch 0 taken 11008 times.
✓ Branch 1 taken 43 times.
11051 for(int32_t i=0; i<256; i++)
7922 {
7923 11008 tmp[i].r=r;
7924 11008 tmp[i].g=g;
7925 11008 tmp[i].b=b;
7926 11008 }
7927
7928 43 fade_interpolate(src,tmp,dest,pos,from,to);
7929 43 }
7930
7931 43 void system_pal()
7932 {
7933 43 is_sys_pal = true;
7934 static PALETTE pal;
7935 43 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
7936
7937 // set up the grayscale palette
7938
2/2
✓ Branch 0 taken 2752 times.
✓ Branch 1 taken 43 times.
2795 for(int32_t i=128; i<192; i++)
7939 {
7940 2752 pal[i].r = i-128;
7941 2752 pal[i].g = i-128;
7942 2752 pal[i].b = i-128;
7943 2752 }
7944 43 load_colorset(gui_colorset, pal, jwin_a5_colors);
7945
7946 43 color_layer(pal, pal, 24,16,16, 28, 128,191);
7947
7948
2/2
✓ Branch 0 taken 5504 times.
✓ Branch 1 taken 43 times.
5547 for(int32_t i=0; i<256; i+=2)
7949 {
7950 5504 int32_t v = (i>>3)+2;
7951 5504 int32_t c = (i>>3)+192;
7952 5504 pal[c] = _RGB(v,v,v+(v>>1));
7953 /*
7954 if(i<240)
7955 {
7956 _allegro_hline(tmp_scr,0,i,319,c);
7957 _allegro_hline(tmp_scr,0,i+1,319,c);
7958 }
7959 */
7960 5504 }
7961
7962 // draw the vertical screen gradient
7963
2/2
✓ Branch 0 taken 10320 times.
✓ Branch 1 taken 43 times.
10363 for(int32_t i=0; i<240; ++i)
7964 {
7965 10320 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
7966 10320 }
7967
7968 /*
7969 palrstart= 10*63/255; palrend=166*63/255;
7970 palgstart= 36*63/255; palgend=202*63/255;
7971 palbstart=106*63/255; palbend=240*63/255;
7972 paldivs=32;
7973 for(int32_t i=0; i<paldivs; i++)
7974 {
7975 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
7976 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
7977 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
7978 }
7979 */
7980 43 BITMAP *panorama = create_bitmap_ex(8,256,224);
7981 int32_t ts_height, ts_start;
7982
7983
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
7984 {
7985 clear_to_color(panorama,0);
7986 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
7987 ts_height=224-passive_subscreen_height;
7988 ts_start=28;
7989 }
7990 else
7991 {
7992 43 blit(framebuf,panorama,0,0,0,0,256,224);
7993 43 ts_height=224;
7994 43 ts_start=0;
7995 }
7996
7997 // gray scale the current frame
7998
2/2
✓ Branch 0 taken 9632 times.
✓ Branch 1 taken 43 times.
9675 for(int32_t y=0; y<ts_height; y++)
7999 {
8000
2/2
✓ Branch 0 taken 2465792 times.
✓ Branch 1 taken 9632 times.
2475424 for(int32_t x=0; x<256; x++)
8001 {
8002 2465792 int32_t c = panorama->line[y+ts_start][x];
8003
2/2
✓ Branch 0 taken 2459902 times.
✓ Branch 1 taken 5890 times.
2465792 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8004 2465792 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8005 2465792 }
8006 9632 }
8007
8008 43 destroy_bitmap(panorama);
8009
8010 // display everything
8011 43 vsync();
8012 43 hw_palette = &pal;
8013 43 update_hw_pal = true;
8014
8015 // sys_pal = pal;
8016 43 memcpy(sys_pal,pal,sizeof(pal));
8017 43 }
8018
8019 void system_pal2()
8020 {
8021 is_sys_pal = true;
8022 static PALETTE RAMpal2;
8023 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8024
8025 /* Windows 2000 colors
8026 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8027 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8028 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8029 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8030 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8031 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8032 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8033 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8034
8035 byte palrstart= 10*63/255, palrend=166*63/255,
8036 palgstart= 36*63/255, palgend=202*63/255,
8037 palbstart=106*63/255, palbend=240*63/255,
8038 paldivs=7;
8039 for(int32_t i=0; i<paldivs; i++)
8040 {
8041 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8042 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8043 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8044 }
8045 */
8046
8047 /* Windows 98 colors
8048 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8049 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8050 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8051 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8052 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8053 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8054 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8055 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8056
8057 byte palrstart= 0*63/255, palrend=166*63/255,
8058 palgstart= 0*63/255, palgend=202*63/255,
8059 palbstart=128*63/255, palbend=240*63/255,
8060 paldivs=7;
8061 for(int32_t i=0; i<paldivs; i++)
8062 {
8063 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8064 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8065 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8066 }
8067 */
8068
8069 /* Windows 99 colors
8070 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8071 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8072 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8073 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8074 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8075 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8076 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8077 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8078 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8079
8080 byte palrstart= 0*63/255, palrend=166*63/255,
8081 palgstart= 0*63/255, palgend=202*63/255,
8082
8083 palbstart=128*63/255, palbend=240*63/255,
8084 paldivs=6;
8085 for(int32_t i=0; i<paldivs; i++)
8086 {
8087 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8088 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8089 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8090 }
8091 */
8092
8093
8094
8095 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8096 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8097 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8098 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8099 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8100 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8101 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8102 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8103 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8104
8105 byte palrstart= 0*63/255, palrend=166*63/255,
8106 palgstart= 0*63/255, palgend=202*63/255,
8107 palbstart=128*63/255, palbend=240*63/255,
8108 paldivs=6;
8109
8110 for(int32_t i=0; i<paldivs; i++)
8111 {
8112 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8113 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8114 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8115 }
8116
8117 gui_bg_color=jwin_pal[jcBOX];
8118 gui_fg_color=jwin_pal[jcBOXFG];
8119
8120 jwin_set_colors(jwin_pal);
8121
8122
8123 // set up the new palette
8124 for(int32_t i=128; i<192; i++)
8125 {
8126 RAMpal2[i].r = i-128;
8127 RAMpal2[i].g = i-128;
8128 RAMpal2[i].b = i-128;
8129 }
8130
8131 /*
8132 for(int32_t i=0; i<64; i++)
8133 {
8134 RAMpal2[128+i] = _RGB(i,i,i)1));
8135 }
8136 */
8137
8138 /*
8139
8140 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8141 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8142 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8143 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8144 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8145 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8146 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8147
8148 gui_fg_color=vc(14);
8149 gui_bg_color=vc(1);
8150
8151 jwin_set_colors(jwin_pal);
8152 */
8153
8154 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8155
8156 // set up the colors for the vertical screen gradient
8157 for(int32_t i=0; i<256; i+=2)
8158 {
8159 int32_t v = (i>>3)+2;
8160 int32_t c = (i>>3)+192;
8161 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8162
8163 /*
8164 if(i<240)
8165 {
8166 _allegro_hline(tmp_scr,0,i,319,c);
8167 _allegro_hline(tmp_scr,0,i+1,319,c);
8168 }
8169 */
8170 }
8171
8172 // hw_palette = &RAMpal;
8173 // update_hw_pal = true;
8174
8175 for(int32_t i=0; i<240; ++i)
8176 {
8177 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8178 }
8179
8180 /*
8181 byte palrstart= 10*63/255, palrend=166*63/255,
8182 palgstart= 36*63/255, palgend=202*63/255,
8183 palbstart=106*63/255, palbend=240*63/255,
8184 paldivs=32;
8185 for(int32_t i=0; i<paldivs; i++)
8186 {
8187 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8188 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8189 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8190 }
8191 */
8192 BITMAP *panorama = create_bitmap_ex(8,256,224);
8193 int32_t ts_height, ts_start;
8194
8195 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8196 {
8197 clear_to_color(panorama,0);
8198 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8199 ts_height=224-passive_subscreen_height;
8200 ts_start=28;
8201 }
8202 else
8203 {
8204 blit(framebuf,panorama,0,0,0,0,256,224);
8205 ts_height=224;
8206 ts_start=0;
8207 }
8208
8209 // gray scale the current frame
8210 for(int32_t y=0; y<ts_height; y++)
8211 {
8212 for(int32_t x=0; x<256; x++)
8213 {
8214 int32_t c = panorama->line[y+ts_start][x];
8215 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8216 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8217 }
8218 }
8219
8220 destroy_bitmap(panorama);
8221
8222 // display everything
8223 vsync();
8224 hw_palette = &RAMpal2;
8225 update_hw_pal = true;
8226
8227 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8228
8229 // sys_pal = pal;
8230 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8231 }
8232
8233 static uint32_t entered_sys_pal = 0;
8234 14 void enter_sys_pal()
8235 {
8236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
8237 {
8238 if(entered_sys_pal)
8239 ++entered_sys_pal;
8240 return;
8241 }
8242 14 system_pal();
8243 14 ++entered_sys_pal;
8244 14 }
8245 14 void exit_sys_pal()
8246 {
8247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
8248 {
8249
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
8250 {
8251 14 game_pal();
8252 14 }
8253 14 }
8254 14 }
8255
8256 void switch_out_callback()
8257 {
8258 if (pause_in_background)
8259 {
8260 callback_switchin = 3;
8261 return;
8262 }
8263
8264 #ifdef _WIN32
8265 if(midi_patch_fix==0 || currmidi==-1)
8266 return;
8267
8268
8269 paused_midi_pos = midi_pos;
8270 zc_stop_midi();
8271 midi_paused=true;
8272 midi_suspended = midissuspHALTED;
8273 #endif
8274 }
8275
8276 void switch_in_callback()
8277 {
8278 if(pause_in_background)
8279 {
8280 return;
8281 }
8282
8283 #ifdef _WIN32
8284 if(midi_patch_fix==0 || currmidi==-1)
8285 return;
8286
8287 else
8288 {
8289 callback_switchin = 1;
8290 midi_suspended = midissuspRESUME;
8291 }
8292 #endif
8293 }
8294
8295 257 void game_pal()
8296 {
8297 257 is_sys_pal = false;
8298 257 entered_sys_pal = 0;
8299 257 clear_to_color(screen,BLACK);
8300 257 hw_palette = &RAMpal;
8301 257 update_hw_pal = true;
8302 257 }
8303
8304 static char bar_str[] = "";
8305
8306 14 void music_pause()
8307 {
8308 //al_pause_duh(tmplayer);
8309 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
8310 14 zc_midi_pause();
8311 14 midi_paused=true;
8312 14 }
8313
8314 void music_resume()
8315 {
8316 //al_resume_duh(tmplayer);
8317 zcmusic_pause(zcmusic, ZCM_RESUME);
8318 zc_midi_resume();
8319 midi_paused=false;
8320 }
8321
8322 5320 void music_stop()
8323 {
8324 //al_stop_duh(tmplayer);
8325 //unload_duh(tmusic);
8326 //tmusic=NULL;
8327 //tmplayer=NULL;
8328 5320 zcmusic_stop(zcmusic);
8329 5320 zcmusic_unload_file(zcmusic);
8330 5320 zc_stop_midi();
8331 5320 midi_paused=false;
8332 5320 currmidi=-1;
8333 5320 }
8334
8335 void System()
8336 {
8337 mouse_down=gui_mouse_b();
8338 music_pause();
8339 pause_all_sfx();
8340 MenuOpen = true;
8341 system_pal();
8342 // FONT *oldfont=font;
8343 // font=tfont;
8344
8345 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8346 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8347
8348 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8349 #if DEVLEVEL > 1
8350 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8351 #endif
8352 game_menu[3].flags =
8353 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8354 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8355 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8356 clear_keybuf();
8357 show_mouse(screen);
8358
8359 DIALOG_PLAYER *p;
8360
8361 clear_bitmap(menu_bmp);
8362 oldscreen = screen;
8363 screen = menu_bmp;
8364
8365 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8366 {
8367 p = init_dialog(system_dlg2,-1);
8368 }
8369 else
8370 {
8371 p = init_dialog(system_dlg,-1);
8372 }
8373
8374 // drop the menu on startup if menu button pressed
8375 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8376 simulate_keypress(KEY_G << 8);
8377
8378 do
8379 {
8380 if(close_button_quit)
8381 {
8382 close_button_quit = false;
8383 f_Quit(qEXIT);
8384 if(Quit) break;
8385 }
8386 rest(17);
8387
8388 if(mouse_down && !gui_mouse_b())
8389 mouse_down=0;
8390
8391 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8392 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8393 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8394
8395 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8396 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8397 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8398 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8399 settings_menu[8].flags = NESquit?D_SELECTED:0;
8400 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8401 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8402 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8403 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8404 settings_menu[13].flags = volkeys?D_SELECTED:0;
8405 //Epilepsy Prevention
8406 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8407
8408 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8409 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8410 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8411
8412 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8413 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8414 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
8415
8416 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8417 cheat_menu[0].flags = 0;
8418 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8419 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8420 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8421 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8422 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8423 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8424 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8425 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8426 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8427
8428 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8429 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8430 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8431 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8432 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8433 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8434 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8435 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8436 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8437 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8438 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8439 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8440 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8441 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8442 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8443
8444 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8445 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8446
8447 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8448 (char *)"Disable recording new saves" :
8449 (char *)"Enable recording new saves";
8450 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8451 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8452 (char *)"Stop recording" :
8453 (char *)"Stop replaying";
8454 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8455 replay_menu[6].text = replay_is_snapshot_all_frames() ?
8456 (char *)"Disable snapshot all frames" :
8457 (char *)"Enable snapshot all frames";
8458
8459 reset_snapshot_format_menu();
8460 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8461
8462 if(debug_enabled)
8463 {
8464 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8465 }
8466
8467 if(gui_mouse_b() && !mouse_down)
8468 break;
8469
8470 // press menu to drop the menu
8471 if(rMbtn())
8472 simulate_keypress(KEY_G << 8);
8473
8474 if(input_idle(true) > after_time())
8475 // run Screeen Saver
8476 {
8477 // Screen saver enabled for now.
8478 clear_keybuf();
8479 scare_mouse();
8480 Matrix(ss_speed, ss_density, 0);
8481 system_pal();
8482 unscare_mouse();
8483 broadcast_dialog_message(MSG_DRAW, 0);
8484 }
8485
8486 update_hw_screen();
8487 }
8488 while(update_dialog(p));
8489
8490 screen = oldscreen;
8491
8492 // font=oldfont;
8493 mouse_down=gui_mouse_b();
8494 shutdown_dialog(p);
8495 show_mouse(NULL);
8496 MenuOpen = false;
8497 if(Quit)
8498 {
8499 kill_sfx();
8500 music_stop();
8501 update_hw_screen();
8502 }
8503 else
8504 {
8505 game_pal();
8506 music_resume();
8507 resume_all_sfx();
8508
8509 if(rc)
8510 ringcolor(false);
8511 }
8512
8513 eat_buttons();
8514
8515 rc=false;
8516 clear_keybuf();
8517 // text_mode(0);
8518 }
8519
8520 29 void fix_dialogs()
8521 {
8522 29 jwin_center_dialog(about_dlg);
8523 29 jwin_center_dialog(gamepad_dlg);
8524 29 jwin_center_dialog(credits_dlg);
8525 29 jwin_center_dialog(gamemode_dlg);
8526 29 jwin_center_dialog(getnum_dlg);
8527 29 jwin_center_dialog(goto_dlg);
8528 29 jwin_center_dialog(keyboard_control_dlg);
8529 29 jwin_center_dialog(midi_dlg);
8530 29 jwin_center_dialog(quest_dlg);
8531 29 jwin_center_dialog(scrsaver_dlg);
8532 29 jwin_center_dialog(sound_dlg);
8533 29 jwin_center_dialog(triforce_dlg);
8534
8535 // digi_dp[1] += scrx;
8536 // digi_dp[2] += scry;
8537 // midi_dp[1] += scrx;
8538 // midi_dp[2] += scry;
8539 // pan_dp[1] += scrx;
8540 // pan_dp[2] += scry;
8541 // emus_dp[1] += scrx;
8542 // emus_dp[2] += scry;
8543 // buf_dp[1] += scrx;
8544 // buf_dp[2] += scry;
8545 // sfx_dp[1] += scrx;
8546 // sfx_dp[2] += scry;
8547 29 }
8548
8549 /*****************************/
8550 /**** Custom Sound System ****/
8551 /*****************************/
8552
8553 2295 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8554 {
8555
3/4
✓ Branch 0 taken 2061 times.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 2295 times.
✗ Branch 3 not taken.
2295 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8556 }
8557
8558 // Run an NSF, or a MIDI if the NSF is missing somehow.
8559 83 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8560 {
8561 83 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8562
8563 // Found it
8564
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 35 times.
83 if(newzcmusic!=NULL)
8565 {
8566 48 zcmusic_stop(zcmusic);
8567 48 zcmusic_unload_file(zcmusic);
8568 48 zc_stop_midi();
8569
8570 48 zcmusic=newzcmusic;
8571 48 zcmusic_play(zcmusic, emusic_volume);
8572
8573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(track>0)
8574 48 zcmusic_change_track(zcmusic,track);
8575
8576 48 return true;
8577 }
8578
8579 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8580
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 else if(midi>-1000)
8581 jukebox(midi);
8582
8583 35 return false;
8584 83 }
8585
8586 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8587 {
8588 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8589 // Found it
8590 if(newzcmusic!=NULL)
8591 {
8592 zcmusic_stop(zcmusic);
8593 zcmusic_unload_file(zcmusic);
8594 zc_stop_midi();
8595
8596 zcmusic=newzcmusic;
8597 zcmusic_play(zcmusic, emusic_volume);
8598
8599 if(track>0)
8600 zcmusic_change_track(zcmusic,track);
8601
8602 return true;
8603 }
8604
8605 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8606 else if(midi>-1000)
8607 jukebox(midi);
8608
8609 return false;
8610 }
8611
8612 int32_t get_zcmusicpos()
8613 {
8614 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8615 return debugtracething;
8616 return 0;
8617 }
8618
8619 void set_zcmusicpos(int32_t position)
8620 {
8621 zcmusic_set_curpos(zcmusic, position);
8622 }
8623
8624 void set_zcmusicspeed(int32_t speed)
8625 {
8626 int32_t newspeed = vbound(speed, 0, 10000);
8627 zcmusic_set_speed(zcmusic, newspeed);
8628 }
8629
8630 1133 void jukebox(int32_t index,int32_t loop)
8631 {
8632 1133 music_stop();
8633
8634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if(index<0) index=MAXMIDIS-1;
8635
8636
1/2
✓ Branch 0 taken 1133 times.
✗ Branch 1 not taken.
1133 if(index>=MAXMIDIS) index=0;
8637
8638 1133 music_stop();
8639
8640 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8641 // stuck notes when a song stops. This fixes it.
8642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1133 times.
1133 if(strcmp(midi_driver->name, "DIGMID")==0)
8643 zc_set_volume(0, 0);
8644
8645 1133 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8646 1133 zc_play_midi((MIDI*)tunes[index].data,loop);
8647
8648
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 377 times.
1133 if(tunes[index].start>0)
8649 377 zc_midi_seek(tunes[index].start);
8650
8651 1133 midi_loop_start = tunes[index].loop_start;
8652 1133 midi_loop_end = tunes[index].loop_end;
8653
8654 1133 currmidi=index;
8655 1133 master_volume(digi_volume,midi_volume);
8656 1133 midi_paused=false;
8657 1133 }
8658
8659 8589 void jukebox(int32_t index)
8660 {
8661
1/2
✓ Branch 0 taken 8589 times.
✗ Branch 1 not taken.
8589 if(index<0) index=MAXMIDIS-1;
8662
8663
1/2
✓ Branch 0 taken 8589 times.
✗ Branch 1 not taken.
8589 if(index>=MAXMIDIS) index=0;
8664
8665 // do nothing if it's already playing
8666
3/4
✓ Branch 0 taken 7456 times.
✓ Branch 1 taken 1133 times.
✓ Branch 2 taken 7456 times.
✗ Branch 3 not taken.
8589 if(index==currmidi && midi_pos>=0)
8667 {
8668 7456 midi_paused=false;
8669 7456 return;
8670 }
8671
8672 1133 jukebox(index,tunes[index].loop);
8673 8589 }
8674
8675 9829 void play_DmapMusic()
8676 {
8677 static char tfile[2048];
8678 static int32_t ttrack=0;
8679 9829 bool domidi=false;
8680
8681
2/2
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 8499 times.
9829 if(DMaps[currdmap].tmusic[0]!=0)
8682 {
8683
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 945 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
1715 if(zcmusic==NULL ||
8684
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8685
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8686 {
8687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945 times.
945 if(zcmusic != NULL)
8688 {
8689 zcmusic_stop(zcmusic);
8690 zcmusic_unload_file(zcmusic);
8691 zcmusic = NULL;
8692 }
8693
8694 945 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8695
8696
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 859 times.
945 if(zcmusic!=NULL)
8697 {
8698 86 zc_stop_midi();
8699 86 strcpy(tfile,DMaps[currdmap].tmusic);
8700 86 zcmusic_play(zcmusic, emusic_volume);
8701 86 int32_t temptracks=0;
8702 86 temptracks=zcmusic_get_tracks(zcmusic);
8703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
8704 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8705 86 zcmusic_change_track(zcmusic,ttrack);
8706 86 }
8707 else
8708 {
8709 859 tfile[0] = 0;
8710 859 domidi=true;
8711 }
8712 945 }
8713 1330 }
8714 else
8715 {
8716 8499 domidi=true;
8717 }
8718
8719
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 9358 times.
9829 if(domidi)
8720 {
8721 9358 int32_t m=DMaps[currdmap].midi;
8722
8723
3/4
✓ Branch 0 taken 9243 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
9358 switch(m)
8724 {
8725 case 1:
8726 105 jukebox(ZC_MIDI_OVERWORLD);
8727 105 break;
8728
8729 case 2:
8730 10 jukebox(ZC_MIDI_DUNGEON);
8731 10 break;
8732
8733 case 3:
8734 jukebox(ZC_MIDI_LEVEL9);
8735 break;
8736
8737 default:
8738
3/4
✓ Branch 0 taken 8329 times.
✓ Branch 1 taken 914 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8329 times.
9243 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8739 8329 jukebox(m+MIDIOFFSET_DMAP);
8740 else
8741 914 music_stop();
8742 9243 }
8743 9358 }
8744 9829 }
8745
8746 9866 void playLevelMusic()
8747 {
8748 9866 int32_t m=tmpscr->screen_midi;
8749
8750
3/6
✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
9866 switch(m)
8751 {
8752 case -2:
8753 12 music_stop();
8754 12 break;
8755
8756 case -1:
8757 9813 play_DmapMusic();
8758 9813 break;
8759
8760 case 1:
8761 jukebox(ZC_MIDI_OVERWORLD);
8762 break;
8763
8764 case 2:
8765 jukebox(ZC_MIDI_DUNGEON);
8766 break;
8767
8768 case 3:
8769 jukebox(ZC_MIDI_LEVEL9);
8770 break;
8771
8772 default:
8773
2/4
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
41 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8774 41 jukebox(m+MIDIOFFSET_MAPSCR);
8775 else
8776 music_stop();
8777 41 }
8778 9866 }
8779
8780 1162 void master_volume(int32_t dv,int32_t mv)
8781 {
8782
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1162 times.
✗ Branch 7 not taken.
1162 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8783
8784
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1162 times.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1162 times.
✗ Branch 7 not taken.
1162 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8785
8786
6/6
✓ Branch 0 taken 1132 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 1160 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 1130 times.
✓ Branch 5 taken 30 times.
1162 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8787 1162 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
8788 1162 }
8789
8790 /*****************/
8791 /***** SFX *****/
8792 /*****************/
8793
8794 // array of voices, one for each sfx sample in the data file
8795 // 0+ = voice #
8796 // -1 = voice not allocated
8797 29 void Z_init_sound()
8798 {
8799
2/2
✓ Branch 0 taken 7424 times.
✓ Branch 1 taken 29 times.
7453 for(int32_t i=0; i<WAV_COUNT; i++)
8800 7424 sfx_voice[i]=-1;
8801
8802
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 29 times.
232 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8803 203 tunes[i].data = (MIDI*)mididata[i].dat;
8804
8805
2/2
✓ Branch 0 taken 7308 times.
✓ Branch 1 taken 29 times.
7337 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8806 7308 tunes[ZC_MIDI_COUNT+j].data=NULL;
8807
8808 29 master_volume(digi_volume,midi_volume);
8809 29 }
8810
8811 // returns number of voices currently allocated
8812 int32_t sfx_count()
8813 {
8814 int32_t c=0;
8815
8816 for(int32_t i=0; i<WAV_COUNT; i++)
8817 if(sfx_voice[i]!=-1)
8818 ++c;
8819
8820 return c;
8821 }
8822
8823 // clean up finished samples
8824 6480723 void sfx_cleanup()
8825 {
8826
2/2
✓ Branch 0 taken 1659065088 times.
✓ Branch 1 taken 6480723 times.
1665545811 for(int32_t i=0; i<WAV_COUNT; i++)
8827
3/4
✓ Branch 0 taken 560755 times.
✓ Branch 1 taken 1658504333 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 560755 times.
1659625843 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8828 {
8829 560755 deallocate_voice(sfx_voice[i]);
8830 560755 sfx_voice[i]=-1;
8831 560755 }
8832 6480723 }
8833
8834 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8835 // if a voice is already allocated (and/or playing), then it just returns true
8836 // Returns true: voice is allocated
8837 // false: unsuccessful
8838 838762 bool sfx_init(int32_t index)
8839 {
8840 // check index
8841
3/4
✓ Branch 0 taken 620761 times.
✓ Branch 1 taken 218001 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 620761 times.
838762 if(index<=0 || index>=WAV_COUNT)
8842 218001 return false;
8843
8844
2/2
✓ Branch 0 taken 59980 times.
✓ Branch 1 taken 560781 times.
620761 if(sfx_voice[index]==-1)
8845 {
8846
2/2
✓ Branch 0 taken 110294 times.
✓ Branch 1 taken 450487 times.
560781 if(sfxdat)
8847 {
8848
1/2
✓ Branch 0 taken 110294 times.
✗ Branch 1 not taken.
110294 if(index<Z35)
8849 {
8850 110294 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8851 110294 }
8852 else
8853 {
8854 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8855 }
8856 110294 }
8857 else
8858 {
8859 450487 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8860 }
8861
8862 560781 voice_set_volume(sfx_voice[index], sfx_volume);
8863 560781 }
8864
8865 620761 return sfx_voice[index] != -1;
8866 838762 }
8867
8868 // plays an sfx sample
8869 732250 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
8870 {
8871
2/2
✓ Branch 0 taken 550996 times.
✓ Branch 1 taken 181254 times.
732250 if(!sfx_init(index))
8872 181254 return;
8873
8874 550996 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8875 550996 voice_set_pan(sfx_voice[index],pan);
8876
8877 550996 int32_t pos = voice_get_position(sfx_voice[index]);
8878
8879
2/2
✓ Branch 0 taken 259936 times.
✓ Branch 1 taken 291060 times.
550996 if(restart) voice_set_position(sfx_voice[index],0);
8880
8881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550996 times.
550996 if(pos<=0)
8882 550996 voice_start(sfx_voice[index]);
8883
8884
3/4
✓ Branch 0 taken 291060 times.
✓ Branch 1 taken 259936 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 291060 times.
550996 if (restart && replay_is_debug())
8885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 291060 times.
291060 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8886 732250 }
8887
8888 // true if sfx is allocated
8889 32243 bool sfx_allocated(int32_t index)
8890 {
8891
3/4
✓ Branch 0 taken 9403 times.
✓ Branch 1 taken 22840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9403 times.
32243 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8892 }
8893
8894 // start it (in loop mode) if it's not already playing,
8895 // otherwise adjust it to play in loop mode -DD
8896 106512 void cont_sfx(int32_t index)
8897 {
8898
2/2
✓ Branch 0 taken 36747 times.
✓ Branch 1 taken 69765 times.
106512 if(!sfx_init(index))
8899 {
8900 36747 return;
8901 }
8902
8903
1/2
✓ Branch 0 taken 69765 times.
✗ Branch 1 not taken.
69765 if(voice_get_position(sfx_voice[index])<=0)
8904 {
8905 69765 voice_set_position(sfx_voice[index],0);
8906 69765 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8907 69765 voice_start(sfx_voice[index]);
8908 69765 }
8909 else
8910 {
8911 adjust_sfx(index, 128, true);
8912 }
8913 106512 }
8914
8915 // adjust parameters while playing
8916 3547 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8917 {
8918
5/6
✓ Branch 0 taken 2124 times.
✓ Branch 1 taken 1423 times.
✓ Branch 2 taken 2124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 2110 times.
3547 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8919 3533 return;
8920
8921 14 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8922 14 voice_set_pan(sfx_voice[index],pan);
8923 3547 }
8924
8925 // pauses a voice
8926 1468 void pause_sfx(int32_t index)
8927 {
8928
3/6
✓ Branch 0 taken 1468 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1468 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1468 times.
1468 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8929 voice_stop(sfx_voice[index]);
8930 1468 }
8931
8932 // resumes a voice
8933 637 void resume_sfx(int32_t index)
8934 {
8935
3/6
✓ Branch 0 taken 637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 637 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 637 times.
637 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8936 voice_start(sfx_voice[index]);
8937 637 }
8938
8939 // pauses all active voices
8940 244 void pause_all_sfx()
8941 {
8942
2/2
✓ Branch 0 taken 62464 times.
✓ Branch 1 taken 244 times.
62708 for(int32_t i=0; i<WAV_COUNT; i++)
8943
2/2
✓ Branch 0 taken 62462 times.
✓ Branch 1 taken 2 times.
62466 if(sfx_voice[i]!=-1)
8944 2 voice_stop(sfx_voice[i]);
8945 244 }
8946
8947 // resumes all paused voices
8948 230 void resume_all_sfx()
8949 {
8950
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 230 times.
59110 for(int32_t i=0; i<WAV_COUNT; i++)
8951
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(sfx_voice[i]!=-1)
8952 voice_start(sfx_voice[i]);
8953 230 }
8954
8955 // stops an sfx and deallocates the voice
8956 5203476 void stop_sfx(int32_t index)
8957 {
8958
3/4
✓ Branch 0 taken 5102116 times.
✓ Branch 1 taken 101360 times.
✓ Branch 2 taken 5102116 times.
✗ Branch 3 not taken.
5203476 if(index<=0 || index>=WAV_COUNT)
8959 101360 return;
8960
8961
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5102103 times.
5102116 if(sfx_voice[index]!=-1)
8962 {
8963 13 deallocate_voice(sfx_voice[index]);
8964 13 sfx_voice[index]=-1;
8965 13 }
8966 5203476 }
8967
8968 // Stops SFX played by Hero's item of the given family
8969 131169 void stop_item_sfx(int32_t family)
8970 {
8971 131169 int32_t id=current_item_id(family);
8972
8973
2/2
✓ Branch 0 taken 130841 times.
✓ Branch 1 taken 328 times.
131169 if(id<0)
8974 130841 return;
8975
8976 328 stop_sfx(itemsbuf[id].usesound);
8977 131169 }
8978
8979 1802 void kill_sfx()
8980 {
8981
2/2
✓ Branch 0 taken 461312 times.
✓ Branch 1 taken 1802 times.
463114 for(int32_t i=0; i<WAV_COUNT; i++)
8982
2/2
✓ Branch 0 taken 461299 times.
✓ Branch 1 taken 13 times.
461325 if(sfx_voice[i]!=-1)
8983 {
8984 13 deallocate_voice(sfx_voice[i]);
8985 13 sfx_voice[i]=-1;
8986 13 }
8987 1802 }
8988
8989 504198 int32_t pan(int32_t x)
8990 {
8991
1/4
✓ Branch 0 taken 504198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
504198 switch(pan_style)
8992 {
8993 case 0:
8994 return 128;
8995
8996 case 1:
8997 504198 return vbound((x>>1)+68,0,255);
8998
8999 case 2:
9000 return vbound(((x*3)>>2)+36,0,255);
9001 }
9002
9003 return vbound(x,0,255);
9004 504198 }
9005
9006 /*******************************/
9007 /******* Input Handlers ********/
9008 /*******************************/
9009
9010 16584516 bool joybtn(int32_t b)
9011 {
9012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16584516 times.
16584516 if(b == 0)
9013 return false;
9014
9015 16584516 return joy[joystick_index].button[b-1].b !=0;
9016 16584516 }
9017
9018 const char* joybtn_name(int32_t b)
9019 {
9020 if(b == 0)
9021 return "";
9022
9023 return joy[joystick_index].button[b-1].name;
9024 }
9025
9026 int32_t next_press_key();
9027
9028 int32_t next_press_btn()
9029 {
9030 clear_keybuf();
9031 /*bool b[joy[joystick_index].num_buttons+1];
9032
9033 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9034 b[i]=joybtn(i);*/
9035
9036 //first, we need to wait until they're pressing no buttons
9037 for(;;)
9038 {
9039 if(keypressed())
9040 {
9041 switch(readkey()>>8)
9042 {
9043 case KEY_ESC:
9044 return -1;
9045
9046 case KEY_SPACE:
9047 return 0;
9048 }
9049 }
9050
9051 poll_joystick();
9052 bool done = true;
9053
9054 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9055 {
9056 if(joybtn(i)) done = false;
9057 }
9058
9059 if(done) break;
9060 rest(1);
9061 }
9062
9063 //now, we need to wait for them to press any button
9064 for(;;)
9065 {
9066 if(keypressed())
9067 {
9068 switch(readkey()>>8)
9069 {
9070 case KEY_ESC:
9071 return -1;
9072
9073 case KEY_SPACE:
9074 return 0;
9075 }
9076 }
9077
9078 poll_joystick();
9079
9080 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9081 {
9082 if(joybtn(i)) return i;
9083 }
9084 rest(1);
9085 }
9086 }
9087
9088 134574253 static bool rButton(bool &btn, bool &flag, bool* rawbtn = nullptr)
9089 {
9090
2/2
✓ Branch 0 taken 129784481 times.
✓ Branch 1 taken 4789772 times.
134574253 bool ret = btn && !flag;
9091
2/2
✓ Branch 0 taken 117573131 times.
✓ Branch 1 taken 17001122 times.
134574253 flag = rawbtn ? *rawbtn : btn;
9092
9093 134574253 return ret;
9094 }
9095 1337132 static bool rButtonPeek(bool btn, bool flag)
9096 {
9097
2/2
✓ Branch 0 taken 1249424 times.
✓ Branch 1 taken 87708 times.
1337132 if(!btn)
9098 {
9099 1249424 return false;
9100 }
9101
2/2
✓ Branch 0 taken 14956 times.
✓ Branch 1 taken 72752 times.
87708 else if(!flag)
9102 {
9103 14956 return true;
9104 }
9105
9106 72752 return false;
9107 1337132 }
9108
9109 // Updated only by keyboard/gamepad.
9110 // If in replay mode, this is set directly by the replay system.
9111 // This should never be read from directly - use control_state instead.
9112 bool raw_control_state[ZC_CONTROL_STATES];
9113
9114 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9115 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9116 // lasts until the next call to load_control_state.
9117 bool control_state[ZC_CONTROL_STATES];
9118 bool disable_control[ZC_CONTROL_STATES];
9119 bool drunk_toggle_state[11];
9120 bool disabledKeys[127];
9121 bool KeyInput[127];
9122 bool KeyPress[127];
9123
9124 bool key_current_frame[127];
9125 bool key_previous_frame[127];
9126
9127 static bool key_system[127];
9128 static bool key_system_previous[127];
9129 static bool key_system_press[127];
9130
9131 bool button_press[ZC_CONTROL_STATES];
9132 bool button_hold[ZC_CONTROL_STATES];
9133
9134 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9135 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9136 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9137 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9138 #define STICK_PRECISION 56 //define your own sensitivity
9139
9140 5438197 void load_control_state()
9141 {
9142 5438197 load_control_called_this_frame = true;
9143
9144
3/4
✓ Branch 0 taken 2566996 times.
✓ Branch 1 taken 2871201 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2566996 times.
5438197 if (replay_get_version() >= 8 && replay_get_version() < 11)
9145 {
9146
2/2
✓ Branch 0 taken 46205928 times.
✓ Branch 1 taken 2566996 times.
48772924 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9147 46205928 down_control_states[i] = raw_control_state[i];
9148 2566996 }
9149
9150
1/2
✓ Branch 0 taken 5438197 times.
✗ Branch 1 not taken.
5438197 if (!replay_is_replaying())
9151 {
9152 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9153 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9154 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9155 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9156 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9157 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9158 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9159 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9160 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9161 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9162 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9163 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9164 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9165 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9166
9167 if(num_joysticks != 0)
9168 {
9169 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9170 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9171 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9172 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9173 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9174 }
9175 else
9176 {
9177 raw_control_state[14] = false;
9178 raw_control_state[15] = false;
9179 raw_control_state[16] = false;
9180 raw_control_state[17] = false;
9181 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9182 }
9183 }
9184
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5438194 times.
5438197 if (replay_is_active())
9185 {
9186
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 4422979 times.
5438194 if (replay_get_version() < 3)
9187 1015215 replay_poll();
9188
3/4
✓ Branch 0 taken 4422979 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2661604 times.
✓ Branch 3 taken 1761375 times.
4422979 else if (replay_is_replaying() && replay_get_version() < 6)
9189 1761375 replay_peek_input();
9190
4/6
✓ Branch 0 taken 2661604 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2566996 times.
✓ Branch 3 taken 94608 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2566996 times.
2661604 else if (replay_is_replaying() && replay_get_version() >= 8 && replay_get_version() < 11)
9191 2566996 replay_peek_input();
9192
2/2
✓ Branch 0 taken 4320728 times.
✓ Branch 1 taken 1117466 times.
5438194 if (replay_get_version() == 8)
9193 1117466 update_keys();
9194 5438194 }
9195
9196 // Some test replay files were made before a serious input bug was fixed, so instead
9197 // of re-doing them or tossing them out, just check for that zplay version.
9198
3/4
✓ Branch 0 taken 5438191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 5316291 times.
5438197 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
9199
2/2
✓ Branch 0 taken 97887438 times.
✓ Branch 1 taken 5438191 times.
103325629 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9200 {
9201 97887438 control_state[i] = raw_control_state[i];
9202
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 48400128 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
97887438 if (botched_input && !control_state[i])
9203 47077142 down_control_states[i] = false;
9204 97887438 }
9205
9206 5438191 button_press[0]=rButton(control_state[0],button_hold[0]);
9207 5438191 button_press[1]=rButton(control_state[1],button_hold[1]);
9208 5438191 button_press[2]=rButton(control_state[2],button_hold[2]);
9209 5438191 button_press[3]=rButton(control_state[3],button_hold[3]);
9210 5438191 button_press[4]=rButton(control_state[4],button_hold[4]);
9211 5438191 button_press[5]=rButton(control_state[5],button_hold[5]);
9212 5438191 button_press[6]=rButton(control_state[6],button_hold[6]);
9213 5438191 button_press[7]=rButton(control_state[7],button_hold[7]);
9214 5438191 button_press[8]=rButton(control_state[8],button_hold[8]);
9215 5438191 button_press[9]=rButton(control_state[9],button_hold[9]);
9216 5438191 button_press[10]=rButton(control_state[10],button_hold[10]);
9217 5438191 button_press[11]=rButton(control_state[11],button_hold[11]);
9218 5438191 button_press[12]=rButton(control_state[12],button_hold[12]);
9219 5438191 button_press[13]=rButton(control_state[13],button_hold[13]);
9220 5438191 button_press[14]=rButton(control_state[14],button_hold[14]);
9221 5438191 button_press[15]=rButton(control_state[15],button_hold[15]);
9222 5438191 button_press[16]=rButton(control_state[16],button_hold[16]);
9223 5438191 button_press[17]=rButton(control_state[17],button_hold[17]);
9224 5438191 }
9225
9226 // Returns true if any game key is pressed. This is needed because keypressed()
9227 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9228 28178162 bool zc_key_pressed()
9229 //may also need to use zc_getrawkey
9230 {
9231
7/10
✓ Branch 0 taken 22800161 times.
✓ Branch 1 taken 5378001 times.
✓ Branch 2 taken 5378001 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5378001 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4533401 times.
✓ Branch 7 taken 4533401 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1621032 times.
29799194 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9232
4/6
✓ Branch 0 taken 4533401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4533401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3418530 times.
✓ Branch 5 taken 3418530 times.
4533401 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9233
4/6
✓ Branch 0 taken 3418530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3418530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2176173 times.
✓ Branch 5 taken 2176173 times.
3418530 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9234
4/6
✓ Branch 0 taken 2176173 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2176173 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1838283 times.
✓ Branch 5 taken 1838283 times.
2176173 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9235
1/2
✓ Branch 0 taken 1838283 times.
✗ Branch 1 not taken.
1838283 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9236
3/4
✓ Branch 0 taken 1736661 times.
✓ Branch 1 taken 101622 times.
✓ Branch 2 taken 1736661 times.
✗ Branch 3 not taken.
1838283 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9237
3/4
✓ Branch 0 taken 1646160 times.
✓ Branch 1 taken 90501 times.
✓ Branch 2 taken 1646160 times.
✗ Branch 3 not taken.
1736661 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9238
3/4
✓ Branch 0 taken 1633476 times.
✓ Branch 1 taken 12684 times.
✓ Branch 2 taken 1633476 times.
✗ Branch 3 not taken.
1646160 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9239
3/4
✓ Branch 0 taken 1623117 times.
✓ Branch 1 taken 10359 times.
✓ Branch 2 taken 1623117 times.
✗ Branch 3 not taken.
1633476 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9240
3/4
✓ Branch 0 taken 1621864 times.
✓ Branch 1 taken 1253 times.
✓ Branch 2 taken 1621864 times.
✗ Branch 3 not taken.
1623117 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9241
3/4
✓ Branch 0 taken 1621821 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 1621821 times.
✗ Branch 3 not taken.
1621864 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9242
3/4
✓ Branch 0 taken 1621051 times.
✓ Branch 1 taken 770 times.
✓ Branch 2 taken 1621051 times.
✗ Branch 3 not taken.
1621821 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9243
2/4
✓ Branch 0 taken 1621051 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1621051 times.
✗ Branch 3 not taken.
1621051 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9244
2/2
✓ Branch 0 taken 1621032 times.
✓ Branch 1 taken 19 times.
1621051 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9245 50489904 return true;
9246
9247 1621032 return false;
9248 6510614 }
9249
9250 108529366 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9251 {
9252 108529366 bool ret = false, drunkstate = false, rawret = false;
9253 108529366 bool* flag = &down_control_states[btn];
9254
2/7
✓ Branch 0 taken 102011933 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6517433 times.
108529366 switch(btn)
9255 {
9256 case btnF12:
9257 ret = zc_getkey(KEY_F12, ignoreDisable);
9258 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
9259 eatEntirely = false;
9260 break;
9261 case btnF11:
9262 ret = zc_getkey(KEY_F11, ignoreDisable);
9263 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
9264 eatEntirely = false;
9265 break;
9266 case btnF5:
9267 ret = zc_getkey(KEY_F5, ignoreDisable);
9268 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
9269 eatEntirely = false;
9270 break;
9271 case btnQ:
9272 ret = zc_getkey(KEY_Q, ignoreDisable);
9273 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
9274 eatEntirely = false;
9275 break;
9276 case btnI:
9277 ret = zc_getkey(KEY_I, ignoreDisable);
9278 rawret = zc_getrawkey(KEY_I, ignoreDisable);
9279 eatEntirely = false;
9280 break;
9281 case btnM:
9282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6517433 times.
6517433 if(FFCore.kb_typing_mode) return false;
9283 6517433 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9284 6517433 eatEntirely = false;
9285 6517433 break;
9286 default: //control_state[] index
9287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102011933 times.
102011933 if(FFCore.kb_typing_mode) return false;
9288
5/6
✓ Branch 0 taken 101784203 times.
✓ Branch 1 taken 227730 times.
✓ Branch 2 taken 2257162 times.
✓ Branch 3 taken 99527041 times.
✓ Branch 4 taken 2257162 times.
✗ Branch 5 not taken.
102011933 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9289
2/2
✓ Branch 0 taken 5491613 times.
✓ Branch 1 taken 96520320 times.
102011933 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9290
4/4
✓ Branch 0 taken 91845546 times.
✓ Branch 1 taken 10166387 times.
✓ Branch 2 taken 1395 times.
✓ Branch 3 taken 10164992 times.
112178320 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9291 102011933 rawret = raw_control_state[btn];
9292 102011933 }
9293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108529366 times.
108529366 assert(flag);
9294
2/2
✓ Branch 0 taken 70505419 times.
✓ Branch 1 taken 38023947 times.
108529366 if(press)
9295 {
9296
2/2
✓ Branch 0 taken 1337132 times.
✓ Branch 1 taken 36686815 times.
38023947 if(peek)
9297 1337132 ret = rButtonPeek(ret, *flag);
9298
3/4
✓ Branch 0 taken 36686815 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17001122 times.
✓ Branch 3 taken 19685693 times.
36686815 else if (replay_is_active() && replay_get_version() < 8) ret = rButton(ret, *flag);
9299 17001122 else ret = rButton(ret, *flag, &rawret);
9300 38023947 }
9301
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 108529366 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
108529366 if(eatEntirely && ret) control_state[btn] = false;
9302
3/4
✓ Branch 0 taken 82010678 times.
✓ Branch 1 taken 26518688 times.
✓ Branch 2 taken 82010678 times.
✗ Branch 3 not taken.
108529366 if(drunk && drunkstate) ret = !ret;
9303 108529366 return ret;
9304 108529366 }
9305
9306 5384201 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9307 {
9308 5384201 byte ret = 0;
9309
2/2
✓ Branch 0 taken 4045008 times.
✓ Branch 1 taken 1339193 times.
5384201 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9310
2/2
✓ Branch 0 taken 5383639 times.
✓ Branch 1 taken 562 times.
5384201 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9311
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9312
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9313
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9314
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9315
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9316
2/2
✓ Branch 0 taken 5383764 times.
✓ Branch 1 taken 437 times.
5384201 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9317 5384201 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9318 }
9319
9320 1114 byte checkIntBtnVal(byte intbtn, byte vals)
9321 {
9322 1114 return intbtn&vals;
9323 }
9324
9325 1281348 bool Up()
9326 {
9327 1281348 return getInput(btnUp);
9328 }
9329 77421 bool Down()
9330 {
9331 77421 return getInput(btnDown);
9332 }
9333 167324 bool Left()
9334 {
9335 167324 return getInput(btnLeft);
9336 }
9337 188659 bool Right()
9338 {
9339 188659 return getInput(btnRight);
9340 }
9341 68115 bool cAbtn()
9342 {
9343 68115 return getInput(btnA);
9344 }
9345 1255212 bool cBbtn()
9346 {
9347 1255212 return getInput(btnB);
9348 }
9349 bool cSbtn()
9350 {
9351 return getInput(btnS);
9352 }
9353 29891 bool cLbtn()
9354 {
9355 29891 return getInput(btnL);
9356 }
9357 29891 bool cRbtn()
9358 {
9359 29891 return getInput(btnR);
9360 }
9361 bool cPbtn()
9362 {
9363 return getInput(btnP);
9364 }
9365 bool cEx1btn()
9366 {
9367 return getInput(btnEx1);
9368 }
9369 bool cEx2btn()
9370 {
9371 return getInput(btnEx2);
9372 }
9373 bool cEx3btn()
9374 {
9375 return getInput(btnEx3);
9376 }
9377 bool cEx4btn()
9378 {
9379 return getInput(btnEx4);
9380 }
9381 bool AxisUp()
9382 {
9383 return getInput(btnAxisUp);
9384 }
9385 bool AxisDown()
9386 {
9387 return getInput(btnAxisDown);
9388 }
9389 bool AxisLeft()
9390 {
9391 return getInput(btnAxisLeft);
9392 }
9393 bool AxisRight()
9394 {
9395 return getInput(btnAxisRight);
9396 }
9397
9398 bool cMbtn()
9399 {
9400 return getInput(btnM);
9401 }
9402 bool cF12()
9403 {
9404 return getInput(btnF12);
9405 }
9406 bool cF11()
9407 {
9408 return getInput(btnF11);
9409 }
9410 bool cF5()
9411 {
9412 return getInput(btnF5);
9413 }
9414 bool cQ()
9415 {
9416 return getInput(btnQ);
9417 }
9418 bool cI()
9419 {
9420 return getInput(btnI);
9421 }
9422
9423 112876 bool rUp()
9424 {
9425 112876 return getInput(btnUp, true);
9426 }
9427 112804 bool rDown()
9428 {
9429 112804 return getInput(btnDown, true);
9430 }
9431 112757 bool rLeft()
9432 {
9433 112757 return getInput(btnLeft, true);
9434 }
9435 112309 bool rRight()
9436 {
9437 112309 return getInput(btnRight, true);
9438 }
9439 2482 bool rAbtn()
9440 {
9441 2482 return getInput(btnA, true);
9442 }
9443 113491 bool rBbtn()
9444 {
9445 113491 return getInput(btnB, true);
9446 }
9447 5266505 bool rSbtn()
9448 {
9449 5266505 return getInput(btnS, true);
9450 }
9451 6510614 bool rMbtn()
9452 {
9453 6510614 return getInput(btnM, true);
9454 }
9455 112109 bool rLbtn()
9456 {
9457 112109 return getInput(btnL, true);
9458 }
9459 112106 bool rRbtn()
9460 {
9461 112106 return getInput(btnR, true);
9462 }
9463 5182404 bool rPbtn()
9464 {
9465 5182404 return getInput(btnP, true);
9466 }
9467 bool rEx1btn()
9468 {
9469 return getInput(btnEx1, true);
9470 }
9471 bool rEx2btn()
9472 {
9473 return getInput(btnEx2, true);
9474 }
9475 122985 bool rEx3btn()
9476 {
9477 122985 return getInput(btnEx3, true);
9478 }
9479 122985 bool rEx4btn()
9480 {
9481 122985 return getInput(btnEx4, true);
9482 }
9483 bool rAxisUp()
9484 {
9485 return getInput(btnAxisUp, true);
9486 }
9487 bool rAxisDown()
9488 {
9489 return getInput(btnAxisDown, true);
9490 }
9491 bool rAxisLeft()
9492 {
9493 return getInput(btnAxisLeft, true);
9494 }
9495 bool rAxisRight()
9496 {
9497 return getInput(btnAxisRight, true);
9498 }
9499
9500 bool rF11()
9501 {
9502 return getInput(btnF11, true);
9503 }
9504 bool rQ()
9505 {
9506 return getInput(btnQ, true);
9507 }
9508 bool rI()
9509 {
9510 return getInput(btnI, true);
9511 }
9512
9513 13317771 bool DrunkUp()
9514 {
9515 13317771 return getInput(btnUp, false, true);
9516 }
9517 12417217 bool DrunkDown()
9518 {
9519 12417217 return getInput(btnDown, false, true);
9520 }
9521 7866450 bool DrunkLeft()
9522 {
9523 7866450 return getInput(btnLeft, false, true);
9524 }
9525 6829749 bool DrunkRight()
9526 {
9527 6829749 return getInput(btnRight, false, true);
9528 }
9529 5759186 bool DrunkcAbtn()
9530 {
9531 5759186 return getInput(btnA, false, true);
9532 }
9533 5722928 bool DrunkcBbtn()
9534 {
9535 5722928 return getInput(btnB, false, true);
9536 }
9537 5152193 bool DrunkcEx1btn()
9538 {
9539 5152193 return getInput(btnEx1, false, true);
9540 }
9541 5152213 bool DrunkcEx2btn()
9542 {
9543 5152213 return getInput(btnEx2, false, true);
9544 }
9545 bool DrunkcSbtn()
9546 {
9547 return getInput(btnS, false, true);
9548 }
9549 bool DrunkcMbtn()
9550 {
9551 return getInput(btnM, false, true);
9552 }
9553 bool DrunkcLbtn()
9554 {
9555 return getInput(btnL, false, true);
9556 }
9557 bool DrunkcRbtn()
9558 {
9559 return getInput(btnR, false, true);
9560 }
9561 bool DrunkcPbtn()
9562 {
9563 return getInput(btnP, false, true);
9564 }
9565
9566 bool DrunkrUp()
9567 {
9568 return getInput(btnUp, true, true);
9569 }
9570 bool DrunkrDown()
9571 {
9572 return getInput(btnDown, true, true);
9573 }
9574 bool DrunkrLeft()
9575 {
9576 return getInput(btnLeft, true, true);
9577 }
9578 bool DrunkrRight()
9579 {
9580 return getInput(btnRight, true, true);
9581 }
9582 4315794 bool DrunkrAbtn()
9583 {
9584 4315794 return getInput(btnA, true, true);
9585 }
9586 4328323 bool DrunkrBbtn()
9587 {
9588 4328323 return getInput(btnB, true, true);
9589 }
9590 71669 bool DrunkrEx1btn()
9591 {
9592 71669 return getInput(btnEx1, true, true);
9593 }
9594 71662 bool DrunkrEx2btn()
9595 {
9596 71662 return getInput(btnEx2, true, true);
9597 }
9598 bool DrunkrEx3btn()
9599 {
9600 return getInput(btnEx3, true, true);
9601 }
9602 bool DrunkrEx4btn()
9603 {
9604 return getInput(btnEx4, true, true);
9605 }
9606 bool DrunkrSbtn()
9607 {
9608 return getInput(btnS, true, true);
9609 }
9610 bool DrunkrMbtn()
9611 {
9612 return getInput(btnM, true, true);
9613 }
9614 4832892 bool DrunkrLbtn()
9615 {
9616 4832892 return getInput(btnL, true, true);
9617 }
9618 4830254 bool DrunkrRbtn()
9619 {
9620 4830254 return getInput(btnR, true, true);
9621 }
9622 bool DrunkrPbtn()
9623 {
9624 return getInput(btnP, true, true);
9625 }
9626
9627 6819 void eat_buttons()
9628 {
9629 6819 getInput(btnA, true, false, true);
9630 6819 getInput(btnB, true, false, true);
9631 6819 getInput(btnS, true, false, true);
9632 6819 getInput(btnM, true, false, true);
9633 6819 getInput(btnL, true, false, true);
9634 6819 getInput(btnR, true, false, true);
9635 6819 getInput(btnP, true, false, true);
9636 6819 getInput(btnEx1, true, false, true);
9637 6819 getInput(btnEx2, true, false, true);
9638 6819 getInput(btnEx3, true, false, true);
9639 6819 getInput(btnEx4, true, false, true);
9640 6819 }
9641
9642 // Is true for the _first frame_ of a key press.
9643 // But! it is possible that a script manually sets the value of KeyPress,
9644 // in which case it will be restored to the "true" value based on `key_current_frame`
9645 // and `key_previous_frame` on the next frame.
9646 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9647 {
9648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9650 {
9651 case KEY_F7:
9652 case KEY_F8:
9653 case KEY_F9:
9654 return KeyPress[k];
9655
9656 default:
9657
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 return KeyPress[k] && !disabledKeys[k];
9658 }
9659 14 }
9660
9661 // Is true for _every frame_ a key is held down.
9662 // But! it is possible that a script manually sets the value of KeyInput,
9663 // in which case it will be restored to the "true" value based on `key_current_frame`
9664 // on the next frame.
9665 bool zc_getkey(int32_t k, bool ignoreDisable)
9666 {
9667 if(ignoreDisable) return KeyInput[k];
9668 switch(k)
9669 {
9670 case KEY_F7:
9671 case KEY_F8:
9672 case KEY_F9:
9673 return KeyInput[k];
9674
9675 default:
9676 return KeyInput[k] && !disabledKeys[k];
9677 }
9678 }
9679
9680 // Reads (and then clears) the current frame key state directly.
9681 // Scripts can also modify `key_current_frame`.
9682 125 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9683 {
9684
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 123 times.
125 if(zc_getrawkey(k, ignoreDisable))
9685 {
9686 2 _key[k]=key[k]=key_current_frame[k]=0;
9687 2 return true;
9688 }
9689 123 _key[k]=key[k]=key_current_frame[k]=0;
9690 123 return false;
9691 125 }
9692
9693 // Reads the current frame key state directly.
9694 // Scripts can also modify `key_current_frame`.
9695 43497761 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9696 {
9697
2/2
✓ Branch 0 taken 36987119 times.
✓ Branch 1 taken 6510642 times.
43497761 if(ignoreDisable) return key_current_frame[k];
9698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510642 times.
6510642 switch(k)
9699 {
9700 case KEY_F7:
9701 case KEY_F8:
9702 case KEY_F9:
9703 return key_current_frame[k];
9704
9705 default:
9706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6510642 times.
6510642 return key_current_frame[k] && !disabledKeys[k];
9707 }
9708 43497761 }
9709
9710 // Only used for a handful of keys, like tilde and Function keys.
9711 // This state is never read within the game.
9712 // It exists so that all keyboard input still functions during replay,
9713 // without inadvertently doing things like toggling throttling if the player
9714 // presses ~
9715 13021293 bool zc_get_system_key(int32_t k)
9716 {
9717 13021293 return key_system[k];
9718 }
9719
9720 // True for the _first_ frame of a key press.
9721 58595526 bool zc_read_system_key(int32_t k)
9722 {
9723 58595526 return key_system_press[k];
9724 }
9725
9726 826847978 bool is_system_key(int32_t k)
9727 {
9728
2/2
✓ Branch 0 taken 768252452 times.
✓ Branch 1 taken 58595526 times.
826847978 switch (k)
9729 {
9730 case KEY_BACKQUOTE:
9731 case KEY_CLOSEBRACE:
9732 case KEY_END:
9733 case KEY_HOME:
9734 case KEY_OPENBRACE:
9735 case KEY_PGDN:
9736 case KEY_PGUP:
9737 case KEY_TAB:
9738 case KEY_TILDE:
9739 58595526 return true;
9740 }
9741 768252452 return is_Fkey(k);
9742 826847978 }
9743
9744 6510614 void update_system_keys()
9745 {
9746
2/2
✓ Branch 0 taken 826847978 times.
✓ Branch 1 taken 6510614 times.
833358592 for (int32_t q = 0; q < 127; ++q)
9747 {
9748
2/2
✓ Branch 0 taken 136722894 times.
✓ Branch 1 taken 690125084 times.
826847978 if (!is_system_key(q))
9749 690125084 continue;
9750
9751 136722894 key_system[q] = key[q];
9752
1/2
✓ Branch 0 taken 136722894 times.
✗ Branch 1 not taken.
136722894 key_system_press[q] = key_system[q] && !key_system_previous[q];
9753 136722894 key_system_previous[q] = key_system[q];
9754 136722894 }
9755 6510614 }
9756
9757 7628080 void update_keys()
9758 {
9759
2/2
✓ Branch 0 taken 968766160 times.
✓ Branch 1 taken 7628080 times.
976394240 for (int32_t q = 0; q < 127; ++q)
9760 {
9761 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9762
1/2
✓ Branch 0 taken 968766160 times.
✗ Branch 1 not taken.
968766160 if (!replay_is_replaying())
9763 key_current_frame[q] = key[q];
9764
9765
2/2
✓ Branch 0 taken 961653306 times.
✓ Branch 1 taken 7112854 times.
968766160 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9766 968766160 KeyInput[q] = key_current_frame[q];
9767 968766160 key_previous_frame[q] = key_current_frame[q];
9768 968766160 }
9769 7628080 }
9770
9771 bool zc_disablekey(int32_t k, bool val)
9772 {
9773 switch(k)
9774 {
9775 case KEY_F7:
9776 case KEY_F8:
9777 case KEY_F9:
9778 return false;
9779
9780 default:
9781 disabledKeys[k] = val;
9782 return true;
9783 }
9784 }
9785
9786 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9787 {
9788 timer=timer;
9789 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9790 }
9791
9792 // these are here so that copy_dialog won't choke when compiling zelda
9793 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
9794 {
9795 return D_O_K;
9796 }
9797
9798 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
9799 {
9800 return D_O_K;
9801 }
9802
9803 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
9804 {
9805 return D_O_K;
9806 }
9807
9808 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
9809 {
9810 return D_O_K;
9811 }
9812
9813 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
9814 {
9815 return D_O_K;
9816 }
9817
9818 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
9819 {
9820 return D_O_K;
9821 }
9822
9823 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
9824 {
9825 return D_O_K;
9826 }
9827
9828 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
9829 {
9830 return D_O_K;
9831 }
9832
9833 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
9834 {
9835 return D_O_K;
9836 }
9837
9838 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
9839 {
9840 return D_O_K;
9841 }
9842
9843 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
9844 {
9845 return D_O_K;
9846 }
9847
9848 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
9849 {
9850 return D_O_K;
9851 }
9852
9853 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
9854 {
9855 return D_O_K;
9856 }
9857
9858 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
9859 {
9860 return D_O_K;
9861 }
9862
9863 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
9864 {
9865 return D_O_K;
9866 }
9867
9868 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
9869 {
9870 return D_O_K;
9871 }
9872
9873 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
9874 {
9875 return D_O_K;
9876 }
9877
9878 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
9879 {
9880 return D_O_K;
9881 }
9882
9883 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
9884 {
9885 return D_O_K;
9886 }
9887
9888 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
9889 {
9890 return D_O_K;
9891 }
9892
9893 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
9894 {
9895 return D_O_K;
9896 }
9897
9898 /*** end of zc_sys.cc ***/
9899
9900